- π³π±Netherlands ericmulder1980
Well it took us 5 years to get to this point. I would suggest we first fix a broken system before we try to improve it. Currently the redirect Url in 3.x is based on the following logic. I really don't want to create a new issue for the 3.x branch so i changed the version of this issue.
- If you have view access to the Group Relationship Entity (which is configured in the Group type permissions : View individual group members) you are redirected to the Group relationship entity. This is very confusing for the actual visitors of a website that uses the Group module.
- If you have view access to the Entity related to the Group Relationship (which is the user that created the relationship) you will be redirected to the user page.
- If you have view access to the Group related to the Group Relationship (which you generally should have since you became a member) you will be redirected to the group page.
- If all else fails we will send you to the frontpage
So the default behaviour is that you will probably never be redirected to the group page. I can't really see a business case where you would not have the "View individual group members" permission OR where you don't have the permission to view your own user page. This logic works very well if you add a node or other entity relation to a group but not for group memberships.
We can turn this issue into a massive change with configurable redirect paths per group type but that will only further delay the solution of this issue. I think for now we need to make a special flow when we are adding a group membership relation. For all other entity types we can keep the logic as is.
Please check attached patch for the 3.x version.
- π³π±Netherlands ericmulder1980
Somehow a use statement fell off. New patch provided.
- π§πͺBelgium kristiaanvandeneynde Antwerp, Belgium
This has been annoying me for quite some time too, but I just have never gotten around to it. It's definitely on my list to commit some day, but I feel like we might want to put this logic in a new type of plugin handler that defaults to the current behavior, but can deviate on a per plugin basis.
- Status changed to Needs review
9 months ago 9:17am 26 March 2024 - πΈπ³Senegal diaodiallo
Thank you @ericmulder1980 I spent almost half a day with this issue and your small code is working perfectly for me.
Changing the status so more user can test and confirm.
If I try to redirect in an hook_form_group_relationship_form_alter hook, my redirect is overwritten.
Method GroupRelationshipForm::Save is should check for existing redirects before overwriting themif (!$form_state->getRedirect()) { if ($group_relationship->access('view')) { $form_state->setRedirectUrl($group_relationship->toUrl()); } etc...
- π©πͺGermany dercheffe Sersheim, Germany
The Patch in #25 works in 2.2 as well as far I could test.