Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Is there any way to have "Role" filter for views? I've looked trough the group's relationships but haven't found anything which allows to filter members by specific roles such as member, moderator, admin, etc.
Thanks in advance.
Comment | File | Size | Author |
---|---|---|---|
#22 | 1510384-22-views_role_filter.patch | 3.41 KB | SebCorbin |
#16 | asd.jpg | 165.7 KB | ifish |
#15 | 1510384-views-role-filter-15.patch | 3.68 KB | SebCorbin |
#10 | 1510384-og_roles-views.patch | 3.23 KB | SebCorbin |
Comments
Comment #1
nedjoAre you using the 7.x-1.x dev branch? You'll need it for the roles views exposure implemented in #1164516: OG Roles in Views: Patch Attached.
Comment #2
creando sensaciones CreditAttribution: creando sensaciones commentedI'm using OG 7.x-2.0 alpha 2. Is there a way to filter by role? I need to make views showing all members of a certain Group role.
Thanks
Comment #3
Pomliane CreditAttribution: Pomliane commentedIt seems OG roles in Views have not been fully implemented in og-7.x-2.x yet—or I'm missing something.
As they appear to be implemented in 7.x-1.x, isn't it a regression/bug?
At least like a major feature, doesn't it?
Comment #4
Sylense CreditAttribution: Sylense commentedsubscribe
Comment #5
creando sensaciones CreditAttribution: creando sensaciones commentedAs I didn't found a solution I made myself a little function to extract them directly from the database:
Returns an array with uid, name and picture-uri of all group members with a certain role.
needs Group id and Role id
Comment #6
SebCorbin CreditAttribution: SebCorbin commentedTagging
Comment #7
Chipie CreditAttribution: Chipie commentedHow can I use this function in a view?
Comment #8
Renee S CreditAttribution: Renee S commentedComment #9
Renee S CreditAttribution: Renee S commentedComment #10
SebCorbin CreditAttribution: SebCorbin commentedThis patch is a test, just throwing it here for testbot
Comment #12
ifish CreditAttribution: ifish commentedIs there still no the most basic work around for this? Thanks in advance..
Comment #13
ifish CreditAttribution: ifish commentedIf possible then a very basic Views PHP Code filter would be awesome for a fast fix. It's possible to show the current user "roles" in the fields section, so I'm wondering if it's possible to use this in the Filter criteria, such as if user has this role, then show.
Comment #14
kaw3939 CreditAttribution: kaw3939 commentedConfirmed - Same problem
Comment #15
SebCorbin CreditAttribution: SebCorbin commentedWalkthrough:
Comments highly welcome
Comment #16
ifish CreditAttribution: ifish commentedI'm not sure if I've done something wrong but I'm getting broken handler error
Comment #17
SebCorbin CreditAttribution: SebCorbin commentedYOu need to flush your caches for the handler to be discovered in og.info
Comment #18
ifish CreditAttribution: ifish commentedWorks great, thanks alot for this! However, it seems like it has removed the "user role field" that was used by OG before, it's now displaying it as an broken handler. Unless I'm doing something wrong.
Comment #19
SebCorbin CreditAttribution: SebCorbin commentedI still have the field "(OG membership from user) OG membership: OG user roles in group" on my end, I left the code providing that field as it was, though the new relationship could be harnessed
Comment #20
ifish CreditAttribution: ifish commentedAh for some reason "class og_handler_field_user_roles extends og_handler_field_prerender_list { " etc was removed.
Also on a side note, I'm not quite sure if it's actually the user role's handler problem but if selecting Operator "Is none of" it doesn't seem to do anything.
Comment #21
amitaibuThanks for working on this.
Leftovers?
user table?
relationship. Also missing dot.
Can you explain?
Comment #22
SebCorbin CreditAttribution: SebCorbin commentedThe FIXME was in fact irrelevant as we cannot have memberships other than related to user entity (I guess?)
As for the "Is none of", I tried it and it works, so if you can provide me you views structure and possibly a query, that'd help me a lot.
New patch attached as per #21 (simplified the class).
Comment #23
amitaibu> The FIXME was in fact irrelevant as we cannot have memberships other than related to user entity (I guess?)
No, the og-membership can be related to any entity. It treats users and nodes the same way.
Comment #24
SebCorbin CreditAttribution: SebCorbin commentedWell, considering the relationship with user already adds a condition on entity_type, this should not be a problem
Comment #25
amitaibu@SebCorbin,
I'm unable to see this filter -- can you attach an exported View so I can see it working?
Comment #26
SebCorbin CreditAttribution: SebCorbin commented@Amitabiu the second exported in this file (http://drupalcode.org/project/l10n_server.git/blob/73fc0cdeffec993c30b51...) makes use of OG Roles filter
Comment #27
bkildow CreditAttribution: bkildow commentedOn my initial test, #22 appears to work for me. I was able to create a new group role, assign some people to it in a group, then display only those people assigned to this role following the walkthrough in #15. Thank you for your efforts!
@Amitaibu, I didn't see this filter at first either. It appears under a different filter grouping: "OG user roles". I was looking under "OG membership" in the filter criteria screen, and I didn't see it. Searching for "role" in this screen also showed it.
Comment #28
amitaibu@SebCorbin, @bkildow
Sorry I'm unable to see it working. Can you please create a simple View based on OG-example content types, and write the steps to reproduce?
Comment #29
SebCorbin CreditAttribution: SebCorbin commentedPreviewed with the node id of the group previously created as parameter: only shows user "test group admin"
Comment #30
amitaibuCommitted, thanks!
Comment #31
tjhart87 CreditAttribution: tjhart87 commentedWhere was this committed? I'm not seeing this in 7.x-2.0-rc4. Was it only added to dev?
Comment #32
SebCorbin CreditAttribution: SebCorbin commentedYes, it's in dev (btw, thanks Amitai :) )
Comment #33
tjhart87 CreditAttribution: tjhart87 commentedApplied patch to rc4 and all is well. Great work guys!