checking whether user is in a specific usergroup

  • Untested:

    {if $specificGroupID|in_array:$user->getGroupIDs()}...{/if}

    didn't work


    ------

    so i tried this instead


    {if 4|in_array:$userProfile->getGroupIDs()}...{/if}


    is it a bad way to do it ?

  • This is exactly how it’s supposed to work. The $specificGroupID has to be replaced by the ID you want to test. So everything you did is correct. :)

    Plugins, Designs, Hosting, Support und mehr: KittMedia

  • This is exactly how it’s supposed to work. The $specificGroupID has to be replaced by the ID you want to test. So everything you did is correct. :)

    i mean i get an error when i use

    {if 4|in_array:$user->getGroupIDs()}...{/if}

  • Let me guess: Undefined index: user.

    Well, you have to adapt it to the user variable being used in the template; typically either $user or $userProfile.

    Gruß, Udo