J James Well-known member Jul 21, 2011 #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.
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 Jul 21, 2011 #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">
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">
J James Well-known member Jul 21, 2011 #3 I managed to do this in the end by creating a user model and joining the permissions to the getUserById() function.
I managed to do this in the end by creating a user model and joining the permissions to the getUserById() function.