I'm trying to create a view that lists the groups that a user is a member of. Not My groups, but groups of a particular member. This view would be useful, for example, as a block on the side of a profile page.

I am using an argument: "User: Uid"

I have tried using relationship provided by og: "Organic groups: Group node (member)"

The closest I have been able to get is this: I can get the groups that the user owns ("manages").

Is there already a way to do this, and I'm just missing it? If so, I would appreciate any pointers.

Or, please let me know if this functionality is not yet present, and I will change this to a feature request.

Thanks!

CommentFileSizeAuthor
#11 user_groups_view.txt4.33 KBhkvd
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bls20’s picture

I need to do the same thing, did you have any success?

nadavoid’s picture

No, I haven't yet.

askibinski’s picture

Actually this isn't that difficult and easy accomplished with a block view.

* create a block view to display USERS
* as argument choose 'provide default argument' and then 'user ID from url'
* next, create a relationship, choose organic groups (group node relationship, probably the only checkbox)
* now you will be able to add a field -> node -> title - don't forget to use the group node relationship!

that's it. You don't even need a filter. Next you will want to display this block on user profile pages like 'user/8'

The difficulty in using relationships is you not necessarily need to start with the content-type you need to end up with.

Benwick’s picture

It works for Me, even to show Group: Members count field..

tevih’s picture

I'm fuzzy about the steps you're saying to take to make this view.

1. block view to display users, as opposed to node? I thought we're trying to make a list of groups (which the user belongs to, which are nodes) not users?

2. Where do you see "provide default argument"? I chose "User: UID" and this excluded all groups the user didnt create.

Thanks for any help you can offer

tevih’s picture

Figured it out - here's some clarification of askibinski's solution

1. create new view of type "User"
2. Click the plus image under "Arguments" to add a new argument of "UID"
3. (You will get errors popping up at this point, but just disregard them)
4. Create a relationship: Organic Groups: Group node (Member)
5. Add a field - I added "node: title" and "organic groups: organic group description"
6. I created a new display of page (I know, OP was asking about block. I was interested in page view.)
7. Path: "user/%/mygroups" to pass the argument to the page
8. Menu: "Tab: My Groups"

jazzdrive3’s picture

Version: 6.x-2.0-rc1 » 6.x-2.0

This proposed solution still doesn't work for me. It still only shows the groups that the user has created.

And I am using official release 2.0.

nicks’s picture

tevih's solution worked fine for me (as in, it showed the groups the user was a member of). However, I encountered an error when trying to add the member count field to this view. I have posted this as a separate issue: #683442: Error when creating a view for groups a user is in, with member count

ngstigator’s picture

Thanks, Albert. Very useful.

AntiNSA’s picture

Priority: Normal » Critical

I have followed the steps, and can create the view, and even the link to the manager... but I have tried for an hour and cant figure out how to get "edit Membership " Link like is found in the default "og_my" view... any ideas?

hkvd’s picture

FileSize
4.33 KB

Hi guys,

I stumbled upon this discussion while struggling to find an answer to the problem in question. I finally managed to create a view which displays all the groups of a particular user (on the user's profile page). I'm attaching an export of my view with this post. The steps involved in creating the view are as follows -

1) Create a new view of type - Node
2) Choose the fields which you want to display (node title, node description etc..). I selected the 'node title' field for displaying the titles of the user's groups.
3) Add the argument - "Organic groups: Member of a group". Then under the "Action to take if argument is not present:" title, select "Provide default argument" and then select the "User ID from URL" option (i selected this option since i wanted to display the view on the user profile page). After doing this, save this argument. This is the only argument that needs to be passed (thats right!! no need to pass a separate uid argument).
4) Add the "Node: Type" filter and select the "Is one of" operator and select "Group" for the node type.

That's all!! You can add sorting criteria and more display fields as per your requirements.

Hope this helps....

dmetzcher’s picture

hkvd: Brilliant and thank you! Your solution was perfect.

tvilms’s picture

Well done hkvd! Just struggled with the same thing and found your post. Problem solved.

bluestarstudios’s picture

Does anybody know how to achieve this in the Drupal 7 version? I need to display all the groups that the user belongs to. Given that some of the "views" namings have changed I'm confused as to how to achieve that. I'm using a Node View... THANKS!

Grayside’s picture

Version: 6.x-2.0 » 7.x-1.x-dev

Need to change the version tag to get help with a different version :)

If I thought this issue were still active, I would say create a new issue, as the answer is likely to be different.

bluestarstudios’s picture

Thanks Grayside. Any help on achieving this would be greatly appreciated.

bluestarstudios’s picture

Status: Active » Fixed

Actually nevermind. Realized that the new OG provides a default view that already does that. Managed to manipulate it to my own needs. Thanks regardless.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

rameshnittali’s picture

Status: Closed (fixed) » Active

Hi Everyone,

I am not able to achieve the above in Drupal 7. I tried with the existing view which is already existing but it only works for the user who has created the group and not for the member of the group. I have a requirement where only Admin creates a group and adds members to the groups. And each member should be able to get the list of groups to which he belongs. Any help would appreciated.

Regards,
Ramesh

podox’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Active » Closed (fixed)

The following is what I am using for Drupal 7:

1. Create a view of type "OG Membership"
2. Add the relationship "OG membership: Group Node from OG membership"
3. Add the contextual filter "OG membership: Entity id". No relationship, and provide default value "User ID from URL"

Then just add any fields you need.

Anonymous’s picture

Issue summary: View changes
Status: Closed (fixed) » Active

I don't think there is a relationship called "OG membership: Group Node from OG membership" in 7.x-2.x?

admin@beerbaitandfishing.com’s picture

FYI, for anyone trying this same thing in drupal 8, do the following.

Add the following to the file - modules/contrib/og/og.views.inc

-----Add ------

$data['og_membership']['node']['relationship'] = [
'real field' => 'entity_id',
'base' => 'node',
'base field' => 'nid',
'label' => t('OG Membership Content'),
'title' => t('OG Membership Content'),
'id' => 'standard',
];
-------------------

Add that under the existing relation between user and og_membership.

Then you should be able to go from user -> og membership -> content ( the group that they're a member of ) and show the rendered group.