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.
As pointed out in views_user.inc when describing views_handler_filter_username():
/*
* Create a list of usernames.
* I worry this will really, really suck for large sites.
* But then, why would large sites create a filter for one particular user?
* Better to go with roles.
*/
We have a requirement to allow the user to filter by Author Name within a specific role. This patch provides similar functionality to the "Taxonomy: Terms for vocabulary name" filters in views_taxonomy.inc, only for Users in Roles as opposed to Terms in Vocabularies.
Would this be better as a contribution? Given the Taxonomy precedent above, it feels like this should be distributed with Views.
Comment | File | Size | Author |
---|---|---|---|
views_user.inc.patch | 2.25 KB | marcp | |
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedI agree that this is useful and worthy of core. In a publishing context, one might want an exposed filter for all editors.
I tried the patch but no additional filters showed up even though I have extra roles and did clear cache.
Anyway, this will make the filter list grow substantially for sites with many roles. Couldn't we define one filter with an Option to specify a role when setting up the filter. See the Option column in the fields section of View form.
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedThe value list array is populated without knowledge of the option, I believe. I'm not sure it's plausible for that to work.
Comment #3
marcp CreditAttribution: marcp commentedHmmm, did the patch apply for you, Moshe? You should see entries in the "Add filter" combo box that are called "Node: Authors in role ____" for each role...
I agree that it clutters up the filter list the same way that the "Taxonomy: Terms for ______" entries do. It'd be great if we could do this with a single filter and utilize the Option ... if it's possible.
Comment #4
marcp CreditAttribution: marcp commentedJust wondering if anyone else has been able to get this patch to work...
Comment #5
merlinofchaos CreditAttribution: merlinofchaos commentedI've applied this, but this gains a similar problem to profile fields, which is that the views cache needs to be cleared before newly added roles will appear. There isn't an easy way to automatically detect this, but I have another solution I think I can implement.
Comment #6
moshe weitzman CreditAttribution: moshe weitzman commentednot sure what you have in mind, but we could just add fapi submit handlers on role form and profile form.
Comment #7
(not verified) CreditAttribution: commented