Cupara Well-known member Aug 19, 2011 #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
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
Cupara Well-known member Aug 20, 2011 #2 I know not 24 hours but figured if peeps see 1 reply they may respond. So anyone have any ideas?
J James Well-known member Aug 20, 2011 #3 It depends how you want to call them. You can use XenForo_Permission::hasPermission() to check if a user has a permission.
It depends how you want to call them. You can use XenForo_Permission::hasPermission() to check if a user has a permission.
Cupara Well-known member Aug 20, 2011 #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');
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');
J James Well-known member Aug 20, 2011 #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.
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.
Cupara Well-known member Aug 20, 2011 #6 I'll do the first way, its shorter. Thanks for the help James, if I have issues, I'll post back.