On the 'admin/user/user/list' page, I would like to view users email addresses alongside with usernames, status, roles, etc. Could someone please help me on this?

Thanks!

Comments

kaakuu’s picture

Email address is visible at user/xxx/edit
xxx being the user number

kevinr’s picture

what were looking to do is to have all the emails in a list though, so we can arrange in ascending and descending order etc., like with the rest of the user data, any ideas?

roger.ajith’s picture

In user module go to user.admin.inc file.
In this two function shown below

1.user_admin_account
2.theme_user_admin_account

With help of above two functions that content will be displayed in that you can add email there.

kevinr’s picture

This seems to be doing the job so far, but i cant get emails to actually output, I think its something to do with this code here

    $form['name'][$account->uid] = array('#value' => theme('username', $account));
	$form['mail'][$account->uid] = array('#value' => theme('mail', $account));
    $form['status'][$account->uid] =  array('#value' => $status[$account->status]);

in the user_admin_account function. Any ideas?

kevinr’s picture

I managed to fix it using $form['mail'][$account->uid] = array('#value' => $account->mail); Thanks for your help! :)

brianosaur’s picture

Hi folks:

I am trying to view and sort the email address in the user management area too. I am not sure if I understand what was done and with what files. Can you break it down for me again?

Thanks.

adam_b’s picture

Patroclas’s picture

Yep - as far s I recall, Views even comes with a user list pre-configured. It should be easy to adapt to what you want

brianosaur’s picture

My views seems to not have anything for it. I will have to check and see again. I might have an older version of views still. I also am using Organic Groups, so I am not sure if that might have altered something.

brianosaur’s picture

Ok, well that should get me set. Thanks all.

kevinr’s picture

I did this by going to this file... modules/user/user.admin.inc and make the following changes:

Around Line 132:

  $header = array(
    array(),
    array('data' => t('Username'), 'field' => 'u.name'),
	array('data' => t('Mail'), 'field' => 'u.mail'),
    array('data' => t('Status'), 'field' => 'u.status'),
    t('Roles'),
    array('data' => t('Member for'), 'field' => 'u.created', 'sort' => 'desc'),
    array('data' => t('Last access'), 'field' => 'u.access'),
    t('Operations')
  );

  if ($filter['join'] != "") {
    $sql = 'SELECT DISTINCT u.uid, u.name, u.mail, u.status, u.created, u.access FROM {users} u LEFT JOIN {users_roles} ur ON u.uid = ur.uid '. $filter['join'] .' WHERE u.uid != 0 '. $filter['where'];
    $query_count = 'SELECT COUNT(DISTINCT u.uid) FROM {users} u LEFT JOIN {users_roles} ur ON u.uid = ur.uid '. $filter['join'] .' WHERE u.uid != 0 '. $filter['where'];
  }
  else {
    $sql = 'SELECT u.uid, u.name, u.mail, u.status, u.created, u.access FROM {users} u WHERE u.uid != 0 '. $filter['where'];
    $query_count = 'SELECT COUNT(u.uid) FROM {users} u WHERE u.uid != 0 '. $filter['where'];
  }

Around Lines 182:

  while ($account = db_fetch_object($result)) {
    $accounts[$account->uid] = '';
    $form['name'][$account->uid] = array('#value' => theme('username', $account));
	$form['mail'][$account->uid] = array('#value' => $account->mail);
    $form['status'][$account->uid] =  array('#value' => $status[$account->status]);
    $users_roles = array();
    $roles_result = db_query('SELECT rid FROM {users_roles} WHERE uid = %d', $account->uid);
    while ($user_role = db_fetch_object($roles_result)) {
      $users_roles[] = $roles[$user_role->rid];
    }
    asort($users_roles);
    $form['roles'][$account->uid][0] = array('#value' => theme('item_list', $users_roles));
    $form['member_for'][$account->uid] = array('#value' => format_interval(time() - $account->created));
    $form['last_access'][$account->uid] =  array('#value' => $account->access ? t('@time ago', array('@time' => format_interval(time() - $account->access))) : t('never'));
    $form['operations'][$account->uid] = array('#value' => l(t('edit'), "user/$account->uid/edit", array('query' => $destination)));
  }

Around Lines 916:

  $header = array(
    theme('table_select_header_cell'),
    array('data' => t('Username'), 'field' => 'u.name'),
	array('data' => t('Mail'), 'field' => 'u.mail'),
    array('data' => t('Status'), 'field' => 'u.status'),
    t('Roles'),
    array('data' => t('Member for'), 'field' => 'u.created', 'sort' => 'desc'),
    array('data' => t('Last access'), 'field' => 'u.access'),
    t('Operations')
  );

  $output = drupal_render($form['options']);
  if (isset($form['name']) && is_array($form['name'])) {
    foreach (element_children($form['name']) as $key) {
      $rows[] = array(
        drupal_render($form['accounts'][$key]),
        drupal_render($form['name'][$key]),
		drupal_render($form['mail'][$key]),
        drupal_render($form['status'][$key]),
        drupal_render($form['roles'][$key]),
        drupal_render($form['member_for'][$key]),
        drupal_render($form['last_access'][$key]),
        drupal_render($form['operations'][$key]),
      );
    }
  }
  else {
    $rows[] = array(array('data' => t('No users available.'), 'colspan' => '7'));
  }

Hope this works for you.

landike’s picture

It helpful.
I thought about this simple way, and I did it.

BUT I want to create view or ALTER user theme - how should I do this - instead of changing core file user.admin.inc
Is there some lightweight module? Or should i write my own???

Please help me with this.

twitter: @landike