WCF: Check User Group Membership

Achtung: Diese Seite ist nur noch Teil eines Archivs und wird in Zukunft entfernt.

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:
{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.
Über den Autor
Ich bin Webentwickler in Stuttgart und administriere Server seit vielen Jahren. In diesem Blog erstelle ich hauptsächlich Tutorials für andere Webentwickler, Webdesigner und Serveradministratoren.
-------------------------------------------------------------------------------------------------------------------------------------
I’m a web developer in Stuttgart, Germany, and server administrator since many years. This blog mainly contains a tutorial set for other web developer, web designer and server administrators.

373 mal gelesen

Kommentare 0

Es wurden keine Einträge gefunden.