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!
Comment | File | Size | Author |
---|---|---|---|
#11 | user_groups_view.txt | 4.33 KB | hkvd |
Comments
Comment #1
bls20 CreditAttribution: bls20 commentedI need to do the same thing, did you have any success?
Comment #2
nadavoid CreditAttribution: nadavoid commentedNo, I haven't yet.
Comment #3
askibinski CreditAttribution: askibinski commentedActually 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.
Comment #4
Benwick CreditAttribution: Benwick commentedIt works for Me, even to show Group: Members count field..
Comment #5
tevih CreditAttribution: tevih commentedI'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
Comment #6
tevih CreditAttribution: tevih commentedFigured 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"
Comment #7
jazzdrive3 CreditAttribution: jazzdrive3 commentedThis 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.
Comment #8
nicks CreditAttribution: nicks commentedtevih'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
Comment #9
ngstigator CreditAttribution: ngstigator commentedThanks, Albert. Very useful.
Comment #10
AntiNSA CreditAttribution: AntiNSA commentedI 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?
Comment #11
hkvd CreditAttribution: hkvd commentedHi 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....
Comment #12
dmetzcher CreditAttribution: dmetzcher commentedhkvd: Brilliant and thank you! Your solution was perfect.
Comment #13
tvilms CreditAttribution: tvilms commentedWell done hkvd! Just struggled with the same thing and found your post. Problem solved.
Comment #14
bluestarstudios CreditAttribution: bluestarstudios commentedDoes 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!
Comment #15
Grayside CreditAttribution: Grayside commentedNeed 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.
Comment #16
bluestarstudios CreditAttribution: bluestarstudios commentedThanks Grayside. Any help on achieving this would be greatly appreciated.
Comment #17
bluestarstudios CreditAttribution: bluestarstudios commentedActually nevermind. Realized that the new OG provides a default view that already does that. Managed to manipulate it to my own needs. Thanks regardless.
Comment #19
rameshnittali CreditAttribution: rameshnittali commentedHi 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
Comment #20
podox CreditAttribution: podox commentedThe 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.
Comment #21
Anonymous (not verified) CreditAttribution: Anonymous commentedI don't think there is a relationship called "OG membership: Group Node from OG membership" in 7.x-2.x?
Comment #22
admin@beerbaitandfishing.com CreditAttribution: admin@beerbaitandfishing.com as a volunteer commentedFYI, 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.