Jump to:

23493 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » How to prevent user from creating top level pages?

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

Page: 1 2
Go to End
Author Topic: 2468 Views
  • Munhoz
    Avatar
    Community Member
    3 Posts

    Re: How to prevent user from creating top level pages? Link to this post

    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();
    }

    2468 Views
Page: 1 2
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.