Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Set content authors permission default


Go to End


2 Posts   679 Views

Avatar
Faloude

Community Member, 55 Posts

29 October 2016 at 11:54pm

There is a setting that configures the Content Authors access to the Settings section (aka SiteConfig). The permission is set to false by default. I want to hardcode this setting to true so I don't need to manually set it to true after every SS install.

The setting is found in the CMS: Security > Groups > Content Authors > Permissions

Avatar
Faloude

Community Member, 55 Posts

14 November 2016 at 2:46am

Solved thanks to 3DGoo. You basically extend the Group Class.

mysite/code/extensions/CustomGroup.php

class CustomGroup extends DataExtension {

    public function requireDefaultRecords() {
        parent::requireDefaultRecords();

        $contentAuthorGroup = Group::get()->filter('Code', 'content-authors')->first();
        if ($contentAuthorGroup) {
            Permission::grant($contentAuthorGroup->ID, 'EDIT_SITECONFIG');
        }
    }
}

mysite/_config/config.yml

Group:
  extensions:
    - CustomGroup

Warning: this will reverse the setting. If it's on, it will be set to off, if it's off, it will be set to on.