function hook_username_alter
Alter the username that is displayed for a user.
Called by format_username() 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 format_username() will return.
$account: The account object passed to format_username().
See also
Related topics
1 invocation of hook_username_alter()
- format_username in includes/
common.inc - Format a username.
File
-
modules/
system/ system.api.php, line 4384
Code
function hook_username_alter(&$name, $account) {
// Display the user's uid instead of name.
if (isset($account->uid)) {
$name = t('User !uid', array(
'!uid' => $account->uid,
));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.