Programmically add custom role filter to views 3.x

<?php
  $user_view
= views_get_view('user');
  if (!
$user_view || !$user_view->access('block')) {
    return;
  }
 
$user_view->add_item('block', 'filter', 'users_roles', 'rid',
    array(
'value' => array('type' => 'int', 'value' => 6, 'operator' => '=')));
?>

因為懶,deploy features懶,懶得使用 DB API
直接拿現成的 views 自己加

24至25小時前註冊使用者:

<?php
 
//after 24 hours
 
$user_view->add_item('block', 'filter', 'users', 'created',
    array(
'value' => array('type' => 'date', 'value' => date('U', strtotime('-24 hours'))), 'operator' => '<='));
 
//before 25 hours
 
$user_view->add_item('block', 'filter', 'users', 'created',
    array(
'value' => array('type' => 'date', 'value' => date('U', strtotime('-25 hours'))), 'operator' => '>'));

?>
Google