[4.0] remove user from user group#30355
[4.0] remove user from user group#30355wilsonge merged 3 commits intojoomla:4.0-devfrom alikon:patch-117
Conversation
libraries/src/User/UserHelper.php
Outdated
There was a problem hiding this comment.
array_search() need to be checked for the result if ($serachResult !== false)
otherwise false will be cast to 0 that will remove wrong element
There was a problem hiding this comment.
The whole change is not needed. Just need to run groups through array_values().
There was a problem hiding this comment.
if you have a better solution i'm happy to close this one....
|
I have tested this item ✅ successfully on 127ef93 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30355. |
|
I have tested this item 🔴 unsuccessfully on 127ef93 See comment. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30355. |
|
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30355. |
|
For clarification, the usage that failed for me (as reported in issue 30324) was calling UserHelper::removeUserFromGroup($userId, $groupId) from PHP code. One the other hand I wrote a minimal custom function that did the job: unset($userGrps[array_search($groupId, $userGrps)]); $user->groups = $userGrps; // Store the data. } This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30355. |
Co-authored-by: Richard Fath <richard67@users.noreply.github.com>
|
please retest |
|
I have tested this item ✅ successfully on 1d44613 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30355. |
|
I have tested this item ✅ successfully on 1d44613 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30355. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30355. |
|
Thanks! |


Pull Request for Issue #30324.
Summary of Changes
all credits goes to @veperr
Testing Instructions
UserHelper::removeUserFromGroup($userId, $groupId)for the last point i've used the CLI command
php cli/joomla.php user:removefromgroupActual result BEFORE applying this Pull Request
despite the successfull message from CLI command the user is not removed from that group ie it is not removed from the
#__user_usergroup_maptableExpected result AFTER applying this Pull Request
the user is removed correctly from that table