1 token_example.module _token_example_get_user()

Builds a list of available user accounts.

Related topics

File

modules/examples/token_example/token_example.module, line 167
Hook implementations for the Token Example module.

Code

function _token_example_get_user() {
  if (!user_access('access user profiles') && 
    !user_access('administer users')) {
    return array();
  }

  $account_query = db_select('users', 'u');
  $account_query->fields('u', array('uid', 'name'));
  $account_query->condition('u.uid', 0, '>');
  $account_query->condition('u.status', 1);
  $account_query->range(0, 10);
  $accounts = $account_query->execute()->fetchAllKeyed();
  $accounts = array_map('check_plain', $accounts);
  return $accounts;
}