GrdPa
Member
Hi,
I'm making an addon for my website and i've an issue with secondary user groups. This function add one secondary user group to a member. But when I use this function many time to add many secondary groups, i've permission issue.
I'm going to edit the member in the admin section and i save only. My permission issue disappears.
Have you an idea ?
Thanks a lot.
I'm making an addon for my website and i've an issue with secondary user groups. This function add one secondary user group to a member. But when I use this function many time to add many secondary groups, i've permission issue.
I'm going to edit the member in the admin section and i save only. My permission issue disappears.
Have you an idea ?
Thanks a lot.
Code:
private function addSecondaryGroup($groupSet, $userId)
{
$writer = XenForo_DataWriter::create('XenForo_DataWriter_User'); // calls the XenForo User DataWriter
if ($userId)
{
$writer->setExistingData($userId); // tells the DW this is existing data to UPDATE an existing user
}
$userModel = XenForo_Model::create('XenForo_Model_User');
$myUser = $userModel->getUserById($userId);
$secondaryGroupIds = explode(',',$myUser['secondary_group_ids']);
array_push($secondaryGroupIds,$groupSet);
$writer->setOption(XenForo_DataWriter_User::OPTION_ADMIN_EDIT, true);
$writer->setSecondaryGroups($secondaryGroupIds);
$writer->rebuildUserGroupRelations();
$writer->rebuildPermissionCombinationId();
$writer->save();
return true;
}
Last edited: