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

Fixed Function "isMemberOfUserGroup" - empty $userGroupId

cclaerhout

Well-known member
#1
This is not really a bug, but still deserves to be checked. When the template helper "ismemberof" is used and its second parameter is null and not an empty array (which is certain coming from an incorrectly thinking implementation of perms of my addon), "true" is returned because of this:

Class: XenForo_Model_User
PHP:
strpos(",{$user['secondary_group_ids']},", ",{$userGroupId},") !== false
The unregistered visitor secondary usergroups ids are blanked, so when the $userGroupId is blanked too the position is found at 0, so is not false.

Since the usergroup id "0" doesn't exist, the easiest "fix" for the content to be perfectly safe is to put at the top of the function a simple check:
PHP:
    if(empty($userGroupId))
     {
       return false;
     }
This should break nothing with existing coding and would avoid an extra template conditional check of the $userGroupId variable.
 
Last edited: