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.

Customising the CMS /

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

Prevent user group from creating pages


Go to End


7 Posts   2148 Views

Avatar
bones

Community Member, 110 Posts

18 June 2012 at 12:51am

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

Community Member, 110 Posts

11 July 2012 at 12:35am

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

Community Member, 56 Posts

11 July 2012 at 2:42am

Edited: 11/07/2012 2:43am

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

Community Member, 110 Posts

14 July 2012 at 2:35am

Edited: 14/07/2012 2:42am

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

Forum Moderator, 1391 Posts

14 July 2012 at 2:52am

Edited: 14/07/2012 2:59am

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

Community Member, 56 Posts

14 July 2012 at 3:03am

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

Community Member, 110 Posts

18 July 2012 at 9:21pm

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.