Usergroup Permissions

Cupara

Well-known member
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
 
I know not 24 hours but figured if peeps see 1 reply they may respond. So anyone have any ideas?
 
It depends how you want to call them. You can use XenForo_Permission::hasPermission() to check if a user has a permission.
 
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');
 
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.
 
I'll do the first way, its shorter. :D

Thanks for the help James, if I have issues, I'll post back.
 
Top Bottom