Filter nodes by whether author account is active/blocked
chris_five - July 3, 2008 - 01:25
| Project: | Views |
| Version: | 5.x-1.x-dev |
| Component: | Views Data |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Jump to:
Description
Small addition to the filters section of views_user.inc. May be slow for site with many users, but no more so than author username filter. Patch attached.
| Attachment | Size |
|---|---|
| views_user.patch | 907 bytes |

#1
Until the patch makes it into Views, this can be accomplished with hook_views_tables_alter(). Something along the lines of this:
<?phpfunction mymodule_views_tables_alter(&$table_data) {
$table_data['users']['filters']['status'] = array(
'name' => t('Node: Author is Active'),
'operator' => 'views_handler_operator_eqneq',
'list' => array(0 => t('blocked'), 1 => t('active')),
'help' => t('This allows you to filter by whether or not the node author is active.')
);
}
?>
Don't forget the clear the cache_views table in order for the new filter to appear in the list.
#2
thanks for your suggestion, but i did originally implement my code in a custom module, and thought that it would be useful enough to be committed.
#3
I believe we do not use the term 'active' in Drupal.
#4
sun - what do you mean? The two statuses available for users are active and blocked (per admin/user/user). The code above is similar to the Active filter created by Usernode.
#5
Yea, Views 2 uses the same terminology. Patch looks reasonable to me.