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.

General Questions /

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

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

[SOLVED] Question about security - admin checking


Go to End


6319 Views

Avatar
Ryan M.

Community Member, 309 Posts

29 May 2010 at 10:30am

Edited: 29/05/2010 11:32am

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?

[SOLVED]:

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