1 user.api.php hook_user_format_name_alter(&$name, $account)

Alter the username that is displayed for a user.

Called by user_format_name() to allow modules to alter the username that's displayed. Can be used to ensure user privacy in situations where $account->name is too revealing.

Parameters

$name: The string that user_format_name() will return.

$account: The account object passed to user_format_name().

See also

user_format_name()

Related topics

File

core/modules/user/user.api.php, line 189
Hooks provided by the User module.

Code

function hook_user_format_name_alter(&$name, $account) {
  // Display the user's uid instead of name.
  if (isset($account->uid)) {
    $name = t('User !uid', array('!uid' => $account->uid));
  }
}