Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Hi,
I created a view listing all the groups and would like to filter/show only groups that the logged in user belongs to - either as group creator, or group user. Is this doable?
Thank you.
Seong
Comments
Comment #2
kristiaanvandeneyndeYes, for now you'll need to start from a Group content view with a relationship to Group. It's not possible yet to go the other way around (but it will be in the near future). Then you can filter to only list memberships and add a relation to the user. Then filter on the user being the current user.
Should be easier to pull off when we have a full release.
Comment #3
kristiaanvandeneyndeComment #4
JulienD CreditAttribution: JulienD as a volunteer commentedI would like to achieve the same purpose but by code. @kristiaanvandeneynde, can you tell me how to load all the group a user has access to?
I got lost when playing with access...
Thanks
Reopening the issue
Comment #5
sumanthkumarc CreditAttribution: sumanthkumarc at Azri Solutions commented@JulienD You can use membership loader service. See the below code.
$user is user object for whom you wish to load the data for.
Comment #6
maxilein CreditAttribution: maxilein commentedClosing, since it seems to be a duplicate of
Comment #7
maxilein CreditAttribution: maxilein commentedComment #8
jedgar1mx CreditAttribution: jedgar1mx commentedThanks @sumanthkumarc, that's exactly what I was looking for.
Comment #9
debasisnaskar CreditAttribution: debasisnaskar as a volunteer and commentedHello @sumanthkumarc
Please help me to print the label of the group! I want to just print the label of the Group Name(just similar to Node title).
I have used your code, it gave me the correct output which serves the other purpose, but could not able the print the Group Name(Label).
Comment #10
naveenvalechaReopening this issue for 3.2.x
The solution mentioned in #2829632: How can I create a view listing all groups that a user belong to? for 1.x doesn't work for 3.2.x
Comment #11
naveenvalechaComment #12
kristiaanvandeneyndePlease don't reopen issues that have been closed for years. File a new one.
Comment #13
naveenvalechaApologies for opening the old one. I have also reverted the version and title to match as it was before.
I have opened a new one #3397547: [3.x] How can I create a view listing all groups that a user belong to?
Looking forward to hear from you there.