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.
By default the user/author filter in views loads all registered users by autocomplete widget.
I want to limit these results by group context for example in a content view with exposed user filter displayed under a group.
I am trying to limit the results by "user from og membership" relation passed to author relation etc but the exposed user filter always show all registered users.
Can anyone help me dealing with this kind of problem?
Cheers
Alex
Comment | File | Size | Author |
---|---|---|---|
#1 | 1893942.og_.views-filter-current-group-members.patch | 6.45 KB | joachim |
Comments
Comment #1
joachim CreditAttribution: joachim commentedHere's a patch.
This adds a custom views filter handler to the user table. The idea is that you'd join to the user table via relationships, then add this handler.
It works with group context to provide a dropdown of group members in the exposed filter form.
So, for example, you could have a view that shows all the nodes in a group. If you know they are all authored by 'editor' members, when you could set up the exposed filter dropdown to show all the members who have the 'editor' role, and so filter the nodes by author.
(I considered having the option for an autocomplete too, but that would require a new autocomplete callback to be added. Perhaps someone can tackle this as a follow-up?)
Comment #2
shushu CreditAttribution: shushu commentedThanks @joachim,
Would it be ok to ask for an exported view as an example for the use of the filter ?
Comment #3
joachim CreditAttribution: joachim commentedDo you mean an exported view as an example? I can't export one from my project, as it's all sorts of custom entities.
But I can give a more detailed example. Suppose we have lots of groups, each with normal members and managers. Managers can create news posts in a group.
Now we want to create a view of news posts, that will appear in each group with a group ID argument. We'd also like to let group members filter by the news post author.
With a normal author exposed filter, you'd get all the users on the site, whereas what you want is to list all the editors in the group the view is currently showing.