Jump to:

23550 Posts in 19336 Topics by 2890 members

General Questions

SilverStripe Forums » General Questions » [SOLVED] Question about security - admin checking

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
Go to End
Author Topic: 2168 Views
  • Ryan M.
    Community Member
    309 Posts

    [SOLVED] Question about security - admin checking Link to this post

    I have this code checking whether a user is a site admin or not:

    public function SiteAdmin() {
    if(Permission::check('ADMIN')) return true;

    It's in Page.php so it can be used by any page on the site.

    It works for the first admin user (the user named admin, the default one created upon installation). However it doesn't work for any other admin users that are under the admin group.

    I've tried variations of the perm code: administrator, administrators, admin... all lower case or upper case or capitalized. Nothing seems to work.

    Any tips?


    The problem was the SiteAdmin checker was nested within another template tag loop. Moving it outside the loop worked.

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