Using Namespace: Joomla\CMS\User\UserHelper
the function UserHelper::removeUserFromGroup
simply does not work
The User would be removed from the group
The user is not removed from the group
Ubuntu 20.04.1 LTS
Apache 2.4.41
PHP 7.4.3
Joomla 4.0 beta 3
The following custom function I wrote works:
private function removeUserFromGroup($userId, $groupId){
$user = User::getInstance($userId);
// $user = new User($userId);
// $user->load($userId);
$userGrps = Access::getGroupsByUser($userId, false);
unset($userGrps[array_search($groupId, $userGrps)]);
$user->groups = $userGrps;
$user->save();
// Store the data.
if (!$user->save())
{
$this->setError($user->getError());
return false;
}
return $user->id;
}
Thank you!
ouch wait ....
despite the successfull removed message that user is still in that usergroup ....
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-08-13 06:36:27 |
Closed_By | ⇒ | alikon |
i cannot confirm, i've tested with CLI
