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.
Hello,
I'm trying to display a list of the members of the group, filtered by the group user role.
If I add "OG User Roles: Role name" filter with custom role parameter (for example, previously created role 'administator'), all works properly, but if want to get member list without members with 'administrator' role, no any roles are shown.
I have just one group type, 1 custom role 'administrator' in it.
Comments
Comment #1
ñull CreditAttribution: ñull commentedSame issue here, trying to list users with their roles in groups. No way to do this when the field remains blank.
Comment #2
nevosa CreditAttribution: nevosa commentedsame issue. fiddling around with the view does not help.
Comment #3
jastraat CreditAttribution: jastraat commentedCould one of you post an export of your view?
Comment #4
whop CreditAttribution: whop commentedHello,
same issue, still no clue.
It works as you wold say for custom roles, but for member and non member roles its not working at all.
If I check OG Role in views...just to display in fields, for memers its epmty, for cusstom one it displays the info.
Thanks for help
Comment #5
griz CreditAttribution: griz commentedSame here. Filtering doesn't work either.
Comment #5.0
griz CreditAttribution: griz commentedtext fixes
Comment #6
mtndan CreditAttribution: mtndan commentedSame issue here - I'm not able to filter by the default "member", "non-member" or "administrator" roles. Only the custom roles.
I suppose a workaround could be to create more custom roles but that seems unnecesssary.
Comment #7
NWOM CreditAttribution: NWOM commentedI'm having the same issue. Here is my exported view as requested by jastraat:
Comment #8
Chetan Sharma CreditAttribution: Chetan Sharma commentedI am not able to see member role in the member list
Comment #9
simon_j_nichols CreditAttribution: simon_j_nichols commentedThe problem is that the "member" and "non-member" roles are not actually stored against the user. So when the roles for the users are retrieved only custom roles and administrator are in the database tables. The "member" and "non-member" role definitions are however defined in the role definition table so they appear in the filter list as options, but the data is never stored against the users to match up to them.
I also thin a number of the logical options for the filter are broken, but different story.
Create a custom role and assign it to every user (using rules maybe) or work around this I think are the only options
Comment #10
gunwald CreditAttribution: gunwald commentedI have the same problem, but agree to simon_j_nichols, that a number of the logical options for the filter are broken. If this would not be the case you could logically work around the problem, that
The problem is, that the logical option Is none of does not work, so you can't exclude any role. Views, if you choose Is none of: administrator members for example, generates a condition like this:
WHERE (( ( [...] (og_users_roles_og_membership__og_role2.name IS NULL ) )))
But it should be:
WHERE (( ( [...] (og_users_roles_og_membership__og_role2.name != 'administrator members' ) )))
Comment #11
Erica_der_Whatkin CreditAttribution: Erica_der_Whatkin commentedI've just spent the last day and a half trying to figure out what's going on here (and writing my own work around module). Please forgive any formatting gaffes.
The query we ultimately want:
This will return all the (user) og_memberships that do not have the specified role.
What we get:
which is useless - by putting those clauses in WHERE instead of LEFT JOIN ON, it's returning an empty set.
The solution, as near as I can figure(and without completely rewriting how OG handles group roles), is to create a custom relationship/join handler for the og_membership/og_users_roles relationship to add the extra ON clauses. Do that, remove the useless WHERE clauses from og_handler_filter_user_roles, and you should be mostly good to go.
Comment #12
nickonom CreditAttribution: nickonom commentedI've added
dpm('test');
to theclass og_handler_filter_user_roles extends views_handler_filter_many_to_one
field handler inog_handler_filter_user_roles.inc
and it shows nothing on a views page with user roles field and unfortunately it returned nothing. So impression is that that handler is not involved at all. Would be nice to finally resolve this issue that is was initially reported back on March 22, 2013.Comment #13
nickonom CreditAttribution: nickonom commentedOne more interesting thing is that when you add the
OG membership: OG user roles in group (OG user roles in group)
filed the view was supposed to pull roles from the database, but in fact it just requests other fields involved completely missing this one:Comment #14
nickonom CreditAttribution: nickonom commentedFor all those who will arrive at this page in search of solution to the problem:
Turns out all you need is to add another relationship to the views page:
OG membership: User from OG membership
So the problem is non-existent here.
Comment #15
JasonSafro CreditAttribution: JasonSafro as a volunteer commentednickonom++