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?


Reply

9 Posts   2491 Views

Avatar
Munhoz

6 June 2010 at 1:58am Community Member, 3 Posts

Try this code in pages.php, it allows only for Administrators...

public function onBeforeWrite() {
if(!Permission::check('ADMIN')){
if (!$this->ParentID) {
       user_error('Cannot create new page at top level', E_USER_ERROR);
    exit();
   }
   }
parent::onBeforeWrite();
}