Bitrix Site Manager

CUser::SetUserGroup

CUser::SetUserGroup(
   int user_id,
   array groups
);

The method SetUserGroup assigns a user to a number of groups. The assignment is stored in the database but does not affect the already authorized user state.

Parameters

Parameter Description
user_id User ID.
groups Array containing the ID's of the user groups.

See Also

Example



<?
// assign a user ID=10 to a group with ID=5
$arGroups = CUser::GetUserGroup(10);
$arGroups[] = 5;
CUser::SetUserGroup(10, $arGroups);
?>