• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Usergroup Permissions

Mythotical

Well-known member
#1
How can I call user group permissions in an add-on? I am looking for the 'clean' way of doing it so that all code is consistent.

Thanks
 

James

Well-known member
#3
It depends how you want to call them. You can use XenForo_Permission::hasPermission() to check if a user has a permission.
 

Mythotical

Well-known member
#4
Well I want to set it up in the file and use say $canViewShop so would I do this:
PHP:
$canViewShop = XenForo_Permission::hasPermission('xshop', 'canViewShop');
 

James

Well-known member
#5
You can do it this way:
PHP:
XenForo_Visitor::getInstance()->hasPermission('xshop', 'canViewShop'))
or this way:
PHP:
XenForo_Permission::hasPermission($user['permissions'], "xshop", "canViewShop");
replacing $user['permissions'] with an array of the current user's permissions.