S
S
Sp1keazyYT2018-07-05 18:07:21
1C-Bitrix
Sp1keazyYT, 2018-07-05 18:07:21

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

1 answer(s)
K
Kudis, 2018-07-06
@Sp1keazyYT

Answer given here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question