The method SetUserGroupArray assigns a user to a number of groups (usually called on the $USER object). The assignment is not stored in the database and will not be restored upon further authorizations. To store the assignment in the
database, use the method CUser::SetUserGroup.
<?
// assign the current user to a group with ID=5
global $USER;
$arGroups = $USER->GetUserGroupArray();
$arGroups[] = 5;
$USER->SetUserGroupArray($arGroups);
?>