CSite::InGroup( $arGroups )
The method checks if the current user is included into the specified groups. Static method.
|arGroups||Array, that contains group IDs.|
Returns true, if the user is a member of the specified groups.
Examples of use
<? // Do not display detail image and description of the user is included into the group with ID=3 $arIBlockElement = false; $arIBlockElement = GetIBlockElement($ID); echo $arIBlockElement['NAME'].'
'; if ( !CSite::InGroup (array(3) ) ): echo $arIBlockElement['DETAIL_TEXT'].'
'; echo ShowImage($arIBlockElement['DETAIL_PICTURE'], 150, 150, 'border="0"', '', true); endif; ?>
<? // Display the name of information block if the user is included into the groups with ID = 4 and 5 if ( CSite::InGroup( array(4,5) ) ): $res = CIBlock::GetByID($_GET["BID"]); if($ar_res = $res->GetNext()) echo $ar_res['NAME']; endif; ?>
The check searches for the matсh with the groups with OR operator, i. e. according to this example:
if ( CSite::InGroup( array(4,5) ) ):
The user with the groups "4" or "5" will be included into the retrieved selection - including users that are members of both groups.