It would be really useful to have a tab on the user account that shows the user's group memberships (with roles ideally).

This is useful for debugging things like access control (as otherwise it takes quite a while to figure out where a user has group roles), and also for site admins.

CommentFileSizeAuthor
#8 views.view_.group_content.yml14.23 KBmatslats

Issue fork group-2715285

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

joachim created an issue. See original summary.

kristiaanvandeneynde’s picture

Hey joachim, we have this functionality in Group 7 but seeing as views is part of core now, how about we provide some views for Group 8? I was thinking of the one you mentioned here and as soon as we have that views relationship issue committed to Group 8, we could work this out.

What do you think?

joachim’s picture

Yup, using views +1.

Though probably doesn't need to wait that views relationship issue, as it seems to me to be more logical to build this view with a Group base rather than User base, since there's only one user.

kristiaanvandeneynde’s picture

Yeah you're right, it shouldn't need to wait. I've just had a solution handed to me by dawehner for #2715011: Missing data_table for Group and GroupContent so I should be able to create a full patch for that one really soon. I suggest we tackle this one right after that issue gets fixed. (Because the views will use different base tables once that one lands)

joachim’s picture

Hmm now I've had a go at this, it looks like it *does* depend on #2706495: add Views reverse relationships from entities to Group Content.

- If I base the view on Group, then the available relationships to Group Content are per-group type. That's no good for a view we'd include in the module as configuration. We need the entity_type column on the group_content table so that we can have a relationship from Group -> Group Content where the entity type is 'user'.
- If I base the view on Group Content, there's the same problem with filtering to Group Content that represents a user's membership
- If I base the view on User, which I don't think is the most logical way to do it, I definitely need that other issue.

kristiaanvandeneynde’s picture

Yeah, thankfully that one will be unblocked rather soon :)

kristiaanvandeneynde’s picture

This is now perfectly possible by adding an exported view (without the UUID!) in config/optional. Will try to fit this in, but feel free to make one yourself.

matslats’s picture

StatusFileSize
new14.23 KB

i'm looking at the group_members view in the latest build.
It adds to the canonical group node a tab called 'members' which lists memberships.
Seems all very proper. But memberships are not what anybody actually wants to see, IMO
I want the same tab with the same name, but which lists users, not groupcontent.
So I'm enclosing a view to replace \Drupal\group\Entity\Controller\GroupContentController AND view group_members with one page group/%/relations called 'Related entities'
It has an exposed filter for the GroupContent types, which by default shows all GroupContent types pertaining to ALL GroupTypes. However this can easily be fixed by extending a views filter.

kristiaanvandeneynde’s picture

The reason we have a non-view version of that page is because Views isn't a hard dependency. I'm all for having the view, but then we need to look at how core swaps out admin/content with a view when Views is enabled.

matslats’s picture

Yes Kristian, There is something similar happening with the entity.user.collection route and entity.node.collection routes that when views is enabled they swop out.
That's the secondary question though. The main question is whether you would have all the GroupContent entities showing under one tab, so that site builders can put actual member entities under other tabs.

jidrone’s picture

Hi Everyone,

This can be done by using this patch #2813405: Add a field to view and edit content's groups, which creates a field in the entity types from Group Content Plugins, to get this result just enable the submodule from the patch and then got to "Manage Display" for users and configure the "Group Content" field formatter as needed.

mortona2k’s picture

Version: 8.x-1.x-dev » 3.3.x-dev

This is easy to do now.

mortona2k’s picture

The group permission for view published groups doesn't seem to be granted to a group admin.
This is working for my administrator user, but doesn't work for an authenticated user who is a group admin.

avpaderno’s picture

Title: show group memberships on a user account tab » Show group memberships on a user account tab
Status: Active » Needs review