1.20.x user.tokens.inc user_token_info()

Implements hook_token_info().

File

modules/user/user.tokens.inc, line 10
Builds placeholder replacement tokens for user-related data.

Code

function user_token_info() {
  $types['user'] = array(
    'name' => t('Users'),
    'description' => t('Tokens related to individual user accounts.'),
    'needs-data' => 'user',
  );
  $types['current-user'] = array(
    'name' => t('Current user'),
    'description' => t('Tokens related to the currently logged in user.'),
    'type' => 'user',
  );

  $user['uid'] = array(
    'name' => t('User ID'),
    'description' => t('The unique ID of the user account.'),
  );
  $user['name'] = array(
    'name' => t('Name'),
    'description' => t('The account username.'),
  );
  $user['link'] = array(
    'name' => t("Name (linked)"),
    'description' => t("The account username (for users with the <em>View user profiles</em> permission it's displayed as a link to the profile page)."),
  );
  $user['mail'] = array(
    'name' => t('Email'),
    'description' => t('The email address of the user account.'),
  );
  $user['ip-address'] = array(
    'name' => t('IP address'),
    'description' => 'The IP address of the user.',
  );
  $user['roles'] = array(
    'name' => t('Roles'),
    'description' => t('The user roles associated with the user account.'),
    'type' => 'array',
  );

  if (config_get('system.core', 'user_pictures')) {
    $user['picture'] = array(
      'name' => t('Picture'),
      'description' => t('The picture of the user.'),
      'type' => 'file',
    );
  }

  $user['last-login'] = array(
    'name' => t('Last login'),
    'description' => t('The date the user last logged in to the site.'),
    'type' => 'date',
  );
  $user['created'] = array(
    'name' => t('Created'),
    'description' => t('The date the user account was created.'),
    'type' => 'date',
  );
  $user['url'] = array(
    'name' => t('URL'),
    'description' => t('The URL of the account profile page.'),
    'type' => 'url',
  );
  $user['edit-url'] = array(
    'name' => t('Edit URL'),
    'description' => t('The URL of the account edit page.'),
    'type' => 'url',
  );
  $user['cancel-url'] = array(
    'name' => t('Account cancellation URL'),
    'description' => t('The URL of the confirm delete page for the user account.'),
    'restricted' => TRUE,
    'type' => 'url',
  );
  $user['one-time-login-url'] = array(
    'name' => t('One-time login URL'),
    'description' => t('The URL of the one-time login page for the user account.'),
    'restricted' => TRUE,
    'type' => 'url',
  );

  return array(
    'types' => $types,
    'tokens' => array('user' => $user),
  );
}