Answer the question
In order to leave comments, you need to log in
What needs to be entered in the code to display the name of the user group in which he is a member, provided that he is not an admin?
Hello. What needs to be entered in the function condition that if the current user's group id was not equal to 1 (that is, he was not an administrator), then the name of the group appeared echo $arMaxGroup['NAME']; with the maximum id from the list of groups in which the user is located, and if this condition is violated, that is, the person has a group id of 1 (that is, he is the site administrator), then the text was displayed from echo. How to do it?
Here is the code:
<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
$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()) {
echo $arMaxGroup['NAME'];
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question