User tests: Successful: Unsuccessful:
Pull Request for Issue #30324.
all credits goes to @veperr
UserHelper::removeUserFromGroup($userId, $groupId)
for the last point i've used the CLI command php cli/joomla.php user:removefromgroup
despite the successfull message from CLI command the user is not removed from that group ie it is not removed from the #__user_usergroup_map
table
the user is removed correctly from that table
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
I have tested this item
Joomla! 4.0.0-beta4-dev Development [ Mañana ] 29-July-2020 18:21 GMT
See comment.
For clarification, the usage that failed for me (as reported in issue 30324) was calling UserHelper::removeUserFromGroup($userId, $groupId) from PHP code.
I did not try the CLI.
One the other hand I wrote a minimal custom function that did the job:
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;
}
Labels |
Added:
?
|
please retest
I have tested this item
Joomla! 4.0.0-beta4-dev Development [ Mañana ] 29-July-2020 18:21 GMT
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-09-15 11:27:38 |
Closed_By | ⇒ | wilsonge | |
Labels |
Added:
?
|
Thanks!
I have tested this item✅ successfully on 127ef93
Works as described.
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30355.