Fixed Function "isMemberOfUserGroup" - empty $userGroupId


Well-known member
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
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:
       return false;
This should break nothing with existing coding and would avoid an extra template conditional check of the $userGroupId variable.
Last edited: