hook_user_format_name_alter

function hook_user_format_name_alter

hook_user_format_name_alter(&$name, $account)

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->getDisplayName() is too revealing.

Parameters

string $name: The string that $account->getDisplayName() will return.

$account: The account object the name belongs to.

See also

\Drupal\Core\Session\AccountInterface->getDisplayName()

Related topics

Hooks
Define functions that alter the behavior of Drupal core.

File

core/modules/user/登录查看完整内容