is there a way to check if the user is in a specific usergroup inside templates
checking whether user is in a specific usergroup
-
- WSC 3.1.x
-
Sprinter -
April 8, 2019 at 9:44 PM
-
-
Untested:
{if $specificGroupID|in_array:$user->getGroupIDs()}...{/if}
-
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.
-
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.
-
alright that makes sense thanks
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!