From time to time users ask how to check for users, who have specific user group memberships. Thus there are several possibilities – based on the area where to check – I want to declare it in this article.
At first you need the ID of the user group whose membership should be checked. You can find it directly in the ACP under Users -> User Groups -> List User Groups. In the first row, beside the icons, you can see a number, which represents the ID of the particular user group. This ID will be used for the check inside the code.
Template
In templates the query is the following:
Just replace the
PHP
In PHP the query is similar:
Again just replace the
At first you need the ID of the user group whose membership should be checked. You can find it directly in the ACP under Users -> User Groups -> List User Groups. In the first row, beside the icons, you can see a number, which represents the ID of the particular user group. This ID will be used for the check inside the code.
Template
In templates the query is the following:
{if GROUP_ID|in_array:$__wcf->user->getGroupIDs()}Content{/if}
Just replace the
GROUP_ID
with the real ID of the user group you want to check. If the user is in this user group the character string Content
is displayed.PHP
In PHP the query is similar:
if (in_array(GROUP_ID, WCF::getUser()->getGroupIDs())) { … }
Again just replace the
GROUP_ID
with the ID of your desired user group.
373 mal gelesen