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.

Customising the CMS

Prevent user group from creating pages


Reply

7 Posts   837 Views

Avatar
bones

18 June 2012 at 12:51am Community Member, 104 Posts

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

Avatar
bones

11 July 2012 at 12:35am Community Member, 104 Posts

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

Avatar
cuSSter

11 July 2012 at 2:42am (Last edited: 11 July 2012 2:43am), Community Member, 56 Posts

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.

Avatar
bones

14 July 2012 at 2:35am (Last edited: 14 July 2012 2:42am), Community Member, 104 Posts

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?

Avatar
martimiz

14 July 2012 at 2:52am (Last edited: 14 July 2012 2:59am), Forum Moderator, 1095 Posts

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...

Avatar
cuSSter

14 July 2012 at 3:03am Community Member, 56 Posts

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.

Avatar
bones

18 July 2012 at 9:21pm Community Member, 104 Posts

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.