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

Methods of Checking User Permissions (Not Visitor)

James

Well-known member
#1
What are the possible methods of checking for the currently logged in user's permissions? I'm trying to do a quick permission check in XenForo_Template_Helper_Core and struggling.
 

Jaxel

Well-known member
#2
There are two ways...

XenForo_Permission::hasPermission($viewingUser['permissions'], 'PermissionGroup', 'PermissionId')
Code:
$viewingUser = null;
$this->standardizeViewingUserReference($viewingUser);

$perms['custom'] = (XenForo_Permission::hasPermission($viewingUser['permissions'], 'EWRporta', 'canCustom') ? true : false);
Or... you can do... (its not the "correct" way)
Code:
$visitor = XenForo_Visitor::getInstance();
$perms['custom'] = ($visitor['permissions']['EWRporta']['canCustom'] ? true : false);
The second method can even be used in templates!
(this may not be the correct way, but I have not run into any issues yet)
Code:
<xen:if is="$visitor.permissions.EWRporta.canCustom">
 

James

Well-known member
#3
I managed to do this in the end by creating a user model and joining the permissions to the getUserById() function.