I have been looking for an answer for 3 days with no success.

Looks like this is a common requirement among plenty of Drupal 8 projects with not a single answer accross the internet about how is possible to achieve it.

I, as user id 1, created 2 groups titled: "Basketball" and "Football" of the group type (sports) and then I added some users as members to those two groups...

So I have something similar to:

Group Title: Basketball

Group Members:

  • User A (whatever role)

  • User B (whatever role)

  • User C (whatever role)

  • User D (whatever role)

Group Title: Football

Group Members:

  • User 1 (whatever role)

  • User 2 (whatever role)

  • User 3 (whatever role)

  • User 4 (whatever role)

Now, what I really want to accomplish using views is to show a table with the names of all available members registered at the same group of the current logged user.

So if for example if User D is the current logged in user, I want to show him a table displaying:

  • User A

  • User B

  • User C

  • User D

without showing up the other members from other groups like user 1, user 2...

and for example if User 2 is the current logged in user, I want to show him a table displaying:

  • User 1

  • User 2

  • User 3

  • User 4

without showing up the other members from other groups like user A, user B...

Is that possible, and how?

I have followed this issue: https://www.drupal.org/node/2793631#comment-11613765 but with no success!

And this question How do I show the members in a block, contextually filtered by the currently logged in user? with no direct solution by using only the views UI.

My aim is to create an entity reference views to be called from a entity reference field element inside a webform.

UPDATE: This issue (https://www.drupal.org/project/group/issues/2793631#comment-12808833) has a solution On how to a list of all groups in which the current logged in user is a member.

However, for my requirement I need to show a list of all members that belong to the same group of the logged in user... so I did:

  • Create a page view and set the content of the view to be Group content with a url: /my-friends

  • Add a relationship to Group (The group containing the entity.)

  • Add a relationship to Group content for User (Relates to the group content entities that represent the User.)

  • Add a contextual filter to Group ID and when the filter value is not available set the default value to User ID from logged in user and the relationship is set to the Group content for User.

For the preview of the view, everything looks good and I, the admin, can see my name inside the display table along with all the other member with me inside the group.

However, if i log in as any other member inside this group such as: User 2 and go to the view page and receive a table with the message: no members available.

  • Where did you get stuck by following the steps in the Issue? It seems to be the way to go.
    – prkos
    Commented Oct 10, 2018 at 16:41
  • Suppose you also have a group Baseball, and User 2 is also member of that group, how to decide if you should display the other members of the Football or Baseball group? PS: the clue to answer your question is "Group Memberships", not mentioned at all in your question ... Commented Oct 10, 2018 at 17:29
  • @prkos please check the update to my question, thank you Commented Oct 10, 2018 at 19:01
  • @Pierre.Vriens if I understand you well, as you can see in my update I am actually using group memberships ! And about the one user as a member in 2 different groups idea, you are 100% right I did not thought of such idea which will for sure happen! Do you recommend any suggestions on how to retrieve the Group ID if this happen ? (I was thinking about an entity reference select list field on the user page which by using it the current user can decide which group he wants to activate !) What do you think ? Commented Oct 10, 2018 at 19:02
  • 1
    @ElieMasaad adding such select list field to "activate" such group is indeed something that might work. However, nowhere in your question I see anything about creating a group membership view (to start from). Am I missing something? Using such view you can then, via relationships, add relevant columns about users, such as their names or whatever. Then add a filter to exclude the current user, and a filter to limit the results to the selected group, and done. Commented Oct 10, 2018 at 19:25

1 Answer 1


I just ran into this today. Found this article and here's the solution I did (only available recently).

I create Content view showing the Content Types that I want. I setup the Relationship to "Content group content" (checkmarking the Content Types I want). I then add a second Relationship to "Group" which is now available (based on the first relationship).

Once the relationships are done, I have access to add a new filter of Group ID. I can manually enter a group ID number and it works... but current user has not been addressed yet.

Now I install: https://www.drupal.org/project/token_views_filter critically, with this patch: https://www.drupal.org/project/token_views_filter/issues/3038695

I can go back into my Group ID filter and checkbox the "Use tokens". Now I can access information about the current user via Tokens.

I felt like I should have been able to setup a Contextual Filter for this... but the system didn't allow for it, so this was my work around.

  • In my instance, I do have a "Current Group ID" field for each user and a custom module that allows them to swap between Groups and sets that ID. The above was an example of me getting current-user tokens to work as Filters (not contextual filters).
    – eahonet
    Commented May 2, 2019 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.