- π§πͺBelgium kristiaanvandeneynde Antwerp, Belgium
Will try to add this to next minor release.
- πΊπΈUnited States jdleonard Austin, TX, USA
The patches are not yet relevant to Group 3.x.
I found that I had to do the following to programmatically add a group role for a user with an existing membership:
// Get the user's membership in the group. $membership = $group->getMember($account); // If the user is already a member of the group. if ($membership) { /** @var \Drupal\group\GroupMembership $membership */ $group_roles = $membership->getRoles(FALSE); $has_member_role = FALSE; foreach ($group_roles as $group_role) { if ($group_role->id() == $member_role) { $has_member_role = TRUE; break; } } // If the user doesn't already have the member role in this group. if (!$has_member_role) { // Add the member role for this user. $group_relationship = $membership->getGroupRelationship(); $group_relationship->group_roles[] = $member_role; $group_relationship->save(); } }
- Status changed to Needs review
10 months ago 1:26pm 16 January 2024 - π¦πΉAustria jordik
Re-rolling the patch to 2.2.x-dev, using the proper groupRelationship instead of groupContent and omitting the changes to ChainGroupPermissionCalculatorTest.php.
- Merge request !136Initial stab at this using the new shared bundle classes. β (Merged) created by kristiaanvandeneynde
- π§πͺBelgium kristiaanvandeneynde Antwerp, Belgium
This needs test coverage for the new methods and I'm not sure if we can simply get away with calling the shared bundle class from the old wrapper like that. For new methods it would make sense, as there is nothing to keep BC for.
- π§πͺBelgium kristiaanvandeneynde Antwerp, Belgium
Hiding patches in favor of MR
- π§πͺBelgium kristiaanvandeneynde Antwerp, Belgium
Okay, this looks ready to me now. Will add a follow-up for moving the role checking logic in a preSave() hook.
- π§πͺBelgium kristiaanvandeneynde Antwerp, Belgium
Change record here: https://www.drupal.org/node/3425776 β
Follow-up here: π Unify preSave and postSave logic for memberships. Active -
kristiaanvandeneynde β
committed 61d81b70 on 3.3.x
Issue #3132084 by kristiaanvandeneynde, LOBsTerr, Aporie, Spokje, JordiK...
-
kristiaanvandeneynde β
committed 61d81b70 on 3.3.x
- Status changed to Fixed
9 months ago 2:37pm 5 March 2024 -
kristiaanvandeneynde β
committed e58eb389 on 2.3.x
Issue #3132084 by kristiaanvandeneynde, LOBsTerr, Aporie, Spokje, JordiK...
-
kristiaanvandeneynde β
committed e58eb389 on 2.3.x
Automatically closed - issue fixed for 2 weeks with no activity.