You are here

function _token_example_get_user in Examples for Developers 7

Same name and namespace in other branches
  1. 6 token_example/token_example.module \_token_example_get_user()

Builds a list of available user accounts.

Related topics

File

token_example/token_example.module, line 186
An example module showing how to define and use tokens.

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;
}