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
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.

AttachmentSize
views_user.patch907 bytes

#1

Roman S - September 11, 2008 - 01:24

Until the patch makes it into Views, this can be accomplished with hook_views_tables_alter(). Something along the lines of this:

<?php
function 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

chris_five - September 17, 2008 - 20:29

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

sun - September 19, 2008 - 04:13
Status:needs review» needs work

I believe we do not use the term 'active' in Drupal.

#4

Roman S - September 20, 2008 - 17:52

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

merlinofchaos - September 20, 2008 - 18:00
Status:needs work» needs review

Yea, Views 2 uses the same terminology. Patch looks reasonable to me.

 
 

Drupal is a registered trademark of Dries Buytaert.