Documentation

GetUserRole

mixed
CSocNetUserToGroup::GetUserRole(
 int userID,
 mixed groupID
);

The method returns user role in the workgroup. When called multiple times, the method does not generate additional database queries. Static method.

Parameters

Parameter Description Available from version
userID User ID.
groupID Workgroup ID, or (from version 8.6.4) array of workgroup IDs.

Returned value

When passing a scalar value in the groupID parameter, one the following values is returned:
SONET_ROLES_MODERATOR - user is a workgroup moderator,
SONET_ROLES_USER - user is a workgroup member,
SONET_ROLES_BAN - user is blacklisted in the workgroup,
SONET_ROLES_REQUEST - request to join the workgroup is sent,
SONET_ROLES_OWNER - user is the workgroup owner,
false - user is not associated with this group.

When (starting from version 8.6.4) array of workgroup IDs is passed in the parameter groupID, returns an associative array with workgroup IDs as keys and values follow the above-described logic.

Example:

Returns value of constants - $Role returns "E", i. e. the value SONET_ROLES_MODERATOR.

<? 
    // $UserID - workgroup $GroupID moderator
    $Role=CSocNetUserToGroup::GetUserRole($UserID,$GroupID);
    echo $Role;
?>


© «Bitrix24», 2001-2024
Up