Answer the question
In order to leave comments, you need to log in
How to take from the sample the user group with the maximum id in which the user is located?
Hello. CUser::GetUserGroupList($USER_ID); - returns a list of all groups the user is a member of, where $USER_ID is the user's id. It is necessary through variables to display the name of the user group in which the user is located, and if the user is in several groups, then the name of only one group is displayed, which is the highest of all by ID. How to do this?
Answer the question
In order to leave comments, you need to log in
What's the problem?
Let's assume that your
highest of all by IDis the one with the maximum id, then for the user with $id = 1:
$obGroups = CUser::GetUserGroupList(1);
$maxGroupId = 0;
while ($arGroup = $obGroups->Fetch()) {
if ($maxGroupId < $arGroup['GROUP_ID']) {
$maxGroupId = $arGroup['GROUP_ID'];
}
}
$obMaxGroup = CGroup::GetByID($maxGroupId);
if ($arMaxGroup = $obMaxGroup->Fetch()) {
var_dump($arMaxGroup);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question