I have a group view which lists the groups on my site
I added the following relationships:
1. Group content
2. (Group content) Group content User

But in the view filter there is no corresponding Group content User to filter on.

There is a current user. But when I add that to (Group content) User current, I get a blank view.

I think i am filtering on the current user who is an author of content in groups. If I have not created any content, this will not work.

I think we need a simple relationship: Group: Member of group

Comments

SocialNicheGuru created an issue. See original summary.

Joel MMCC’s picture

I think this already exists. If I understand your situation correctly, your View is of Entity type Groups, meaning that is the base Entity type returned (as opposed to Users, Nodes, Taxonomy Terms, etc.).

I’m not sure how it works in 8.x, but in 7.x the Group module and its submodules implement the following Entity types:

  • Group Type
    • Group
      • Group Membership
        • User
      • Group Child Entities
        • Nodes (gnode)
        • Profiles (gprofile)
        • Groups (subgroup)
        • Others (you’d need to write your own submodule for other Entities or see if someone else has already done so)

A Group Membership entity connects a User to a Group. This forms a many-to-many relationship which would otherwise be impossible to do directly in Views: a Group can have more than one Member User, and a User can be a Member of more than one Group, so simple many-to-one relationships won’t suffice.

So what you need to do is add a Relationship from your Group to Group Memberships, and in there you’ll find the User ID, and should be able to Filter that based on the Current User (for security and to prevent information disclosure, do not use Contextual Filters for this, since those can be overridden by simply specifying someone else’s UID in the URL.

Again: This is regarding 7.x, which is what I’m familiar with. I’ve read that 8.x works very differently with regard to child entities (using a Group Content entity type as a many-to-many connector entity which is itself fieldable, opening up some very intriguing possibilities), but don’t know how it differs with Group Memberships.

Joel MMCC’s picture

Another possibility would be to redo your View as a View of entity type Users Filtered to only the Current User, then add a Relationship to Group Memberships to retrieve the Groups that the User is a member of, and from there you can also pull in Child Entities such as GNodes for each such Group. Use Views Grouping (a separate thing from Groups) to Group the View based on the Groups which the User is a Member of, and the GNodes under each such Views Grouping subheader.

socialnicheguru’s picture

Category: Support request » Feature request

Drupal 7.x is a little more feature rich that is why I specified it for Drupal 8.x

The relation is not there.

I think I should make it a feature request.

I cannot redo the view as it provided by a distribution

Joel MMCC’s picture

You should be able to clone the View, even if from a distribution.

jdearie’s picture

the reverse (user first) method described in #3 worked for me. I didn't bother to do any grouping since all i wanted was a simple list of groups the logged in user belonged to. thx!!

juagarc4’s picture

You can try this solution: https://www.drupal.org/project/group/issues/2793631#comment-11613765

And here there is another solution: https://www.drupal.org/project/group/issues/2829632

Both worked for me, but I've used finally the first one because it was better for my current configuration.

Regards

dwkitchen’s picture