Jump to:

5539 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Prevent user group from creating pages

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

Page: 1
Go to End
Author Topic: 808 Views
  • bones
    Avatar
    Community Member
    104 Posts

    Prevent user group from creating pages Link to this post

    Is there a way to edit a user group's permissions to prevent them from adding and deleting pages from the site tree?

    I still want Admins to have this functionality though.

    Thanks

  • bones
    Avatar
    Community Member
    104 Posts

    Re: Prevent user group from creating pages Link to this post

    From the lack of replies, it looks as if this isn't possible.

    I really need to prevent users from creating new pages. Where in the code can I "comment out" the code for the create button?

    Thanks

  • cuSSter
    Avatar
    Community Member
    56 Posts

    Re: Prevent user group from creating pages Link to this post

    Hi bones,

    In the Security tab in the CMS, you can create a group and assign permissions for that particular group through the Permissions tab.

  • bones
    Avatar
    Community Member
    104 Posts

    Re: Prevent user group from creating pages Link to this post

    Thanks for the reply, cuSSter, but there doesn't seem to be a way to remove the "Create" button from a group.

    I've created a new group, tried many permutations of permissions settings, and added a new user. When I log in as that user, the "Create" button still appears at the top of the site tree.

    Which of the permissions should I untick to remove the "Create Page" option?

  • martimiz
    Avatar
    Forum Moderator
    1078 Posts

    Re: Prevent user group from creating pages Link to this post

    You might try to use the page's canCreate() function and return false if the current user is not an admin. Something like:

    function canCreate($Member = null) {
       if (!Permission::check("ADMIN")) {
          return false;
       } else {
          return parent::canCreate($member);
       }
    }


    The create button and dropdown will still be there, but the dropdown will at least be empty...

  • cuSSter
    Avatar
    Community Member
    56 Posts

    Re: Prevent user group from creating pages Link to this post

    martimiz is right. Put that in Page.php and no one can create Pages unless they belong to the administrators group. Or add new permission for Page manipulation, I think it's more neat. So you can fully control which user groups will have such permissions on a page. Here's a simple tutorial on how to achieve that: http://www.balbuss.com/ under the Members and security tab.

  • bones
    Avatar
    Community Member
    104 Posts

    Re: Prevent user group from creating pages Link to this post

    Thanks, these look like good solutions, I'll give them a try.

    Currently, for quickness, I've just commented out the "Create" button in cms/templates/includes/CMSMain_left.ss It's not an elegant solution, but it does the job.

    808 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.