Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi all,
I'm using Rules to:
- assign a "special role" to a user when "User membership has been approved" -> Ok, no problem, works correctly
- remove the same "special role" from user when "User has been removed from group" -> BUG triggered
BUG explanation for point 2:
- A group admin try to remove "user A" from his group in "/group/node/XXX/admin/people"
- "User A" is NOT REMOVED from group, but...
- The "special role" is correctly removed from "user A"
What's wrong?
Thank you
Comments
Comment #1
CarolineCB CreditAttribution: CarolineCB commentedI have the exact same problem. Did you ever find a way to correct it? I even tried adding "Unsubcribe user from group" and "Remove entity from group" after I saved the user but it doesn't work. Is there a way to remove a user from a group programatically? I've found og_group() to add them but none to remove them.
Comment #2
CarolineCB CreditAttribution: CarolineCB commentedI found it!
After saving the user without the new group, I added the line:
og_ungroup('node', $og_membership->gid, 'user', $account);
And now the user was removed from the group.