In addition to the email option I would like to list the inactive users in a block on the main page. I want to specify the criteria such as 'inactive for 6 months to 1 years' for the the block.

This could be done if the views integration was done as well.

Comments

udvranto’s picture

I implemented for my own site

function sachalayatan_inactive_users()
{
 $users = array();
 $items = array();
 $cache = cache_get('sachalayatan_inactive_users');
 if (empty($cache->data)) {
    $number = variable_get('sachalayatan_inactive_users_items', 5);
    $numday = variable_get('sachalayatan_inactive_users_days', 180);;
    $result = db_query("SELECT u.uid, u.name FROM {users} u INNER JOIN {users_roles} ur ON ur.uid = u.uid WHERE u.status = 1 AND ur.rid IN (3,5,6,12,13,14,17) AND u.uid NOT IN ( SELECT n.uid FROM {node} n WHERE n.status = 1 AND DATEDIFF(NOW(), FROM_UNIXTIME(n.created)) < %d ) ORDER BY RAND() LIMIT %d",$numday, $number);
    $items = array();
    while ($user = db_fetch_object($result)) {
      $users[] = $user;
    }

    cache_set('sachalayatan_inactive_users',serialize($users));
  }
  else {
    $users = unserialize($cache->data);
  }

  foreach ($users as $user) {
    $items[] = l($user->name, 'user/'. $user->uid );
  }

  if ($items) {
    return theme('item_list', $items);
  }

}