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.

General Questions

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

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

How to prevent user from creating top level pages?

Go to End

9 Posts   2490 Views


8 December 2009 at 9:32am Community Member, 128 Posts

What permissions should be granted to user to enable logging in and edit specific pages but to prevent him/her from creation of the top level pages?

It looks like Access to SiteContent allows creation of top level pages

Thank you



14 January 2010 at 7:21pm Community Member, 105 Posts

Don't think SilverStripe does this out of the box, you could do something with onBeforeWrite to check the members Group before allowing the write to the database.


14 January 2010 at 8:16pm Community Member, 901 Posts

I think you should write a custom canCreate method for your Page Class. There you would check Page-Level and Usergroup and grant/deny accordingly.


14 January 2010 at 8:33pm Community Member, 901 Posts

Sorry, disregard my previous post. The canCreate approach isn't going to work, unless you figure out a way to determine which Page is currently selected in the SiteTree (I would be interested to know this as well).
A thing that's going to work is overriding the canPublish method. This won't prevent the user from creating Pages, but you can make sure that he can never publish them at top level.


4 March 2010 at 10:35pm Community Member, 98 Posts

Would the onBeforeWrite method work to prevent users creating pages at all? I would rather limited users not be able to do this in the CMS rather than having a bunch of unwanted drafts they can never publish.

Please let me know. Thanks!


11 March 2010 at 9:34am Community Member, 1 Post

I'm having the same issue. Did anyone find a solution?


11 March 2010 at 11:10pm Community Member, 98 Posts

Well this is one solution I found, though I'm not proud of it and I'm sure there are better ways that I'm yet to discover.

With this method, you set up the root pages you need first, then once created add this line to your Page class:

static $can_be_root = false;

This then locks out the possibilty of creating any more pages in root. The only issue is that this is global i.e. for all users including admin.

To create more pages, you'd have to set it to true and probably need to do a /dev/build.

I'm gonna stick with this option for now, but am definitely open to a more flexible approach.


12 March 2010 at 12:48am Community Member, 128 Posts

Looking at 2.4 beta 1 with CMS workflow I see

Who can create pages in the root of the site?

with 2 radio buttons

* Anyone who can log-in to the CMS
* Only these people (choose from list)

So we decided just to wait until 2.4 release before extending list of people with access


Go to Top