function hook_user_format_name_alter in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/user/user.api.php \hook_user_format_name_alter()
Alter the username that is displayed for a user.
Called by $account->getDisplayName() to allow modules to alter the username that is displayed. Can be used to ensure user privacy in situations where $account->name is too revealing.
Parameters
string $name: The string that $account->getDisplayName() will return.
$account: The account object passed to user_format_name().
See also
$account->getDisplayName()
Related topics
1 function implements hook_user_format_name_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- user_hooks_test_user_format_name_alter in core/
modules/ user/ tests/ modules/ user_hooks_test/ user_hooks_test.module - Implements hook_user_format_name_alter().
File
- core/
modules/ user/ user.api.php, line 120 - Hooks provided by the User module.
Code
function hook_user_format_name_alter(&$name, $account) {
// Display the user's uid instead of name.
if ($account
->id()) {
$name = t('User @uid', array(
'@uid' => $account
->id(),
));
}
}