Skip to content

Commit

Permalink
ENH Add config to control if a default author is added to posts on c…
Browse files Browse the repository at this point in the history
…reation
  • Loading branch information
jellygnite committed Mar 3, 2022
1 parent 75d0a7d commit df4e42b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/node_modules/
**/*.js.map
**/*.css.map
/.vs
9 changes: 8 additions & 1 deletion src/Model/BlogPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ class BlogPost extends Page
*/
private static $minutes_to_read_wpm = 200;

/**
* Control whether the current member is added to list of authors when a post is created
*
* @var bool
*/
private static $add_default_author = true;

/**
* Sets the upload directory for featured images to help keep your files organised
*
Expand Down Expand Up @@ -818,7 +825,7 @@ protected function onBeforeWrite()
{
parent::onBeforeWrite();

if (!$this->exists() && ($member = Security::getCurrentUser())) {
if (!$this->exists() && $this->config()->get('add_default_author') && ($member = Security::getCurrentUser())) {
$this->Authors()->add($member);
}
}
Expand Down

0 comments on commit df4e42b

Please sign in to comment.