function user_format_name

Format a username.

By default, the passed-in object's 'name' property is used if it exists, or else, the site-defined value for the 'anonymous' variable. However, a module may override this by implementing hook_user_format_name_alter(&$name, $account).

Parameters

$account: The account object for the user whose name is to be formatted.

Return value

An unsanitized string with the username to display. The code receiving this result must ensure that check_plain() is called on it before it is printed to the page.

See also

hook_user_format_name_alter()

20 calls to user_format_name()
contact_mail in drupal/core/modules/contact/contact.module
Implements hook_mail().
contact_personal_form in drupal/core/modules/contact/contact.pages.inc
Page callback: Form constructor for the personal contact form.
contact_site_form in drupal/core/modules/contact/contact.pages.inc
Page callback: Form constructor for the site-wide contact form.
FileTokenReplaceTest::testFileTokenReplacement in drupal/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php
Creates a file, then tests the tokens generated from it.
hook_mail in drupal/core/modules/system/system.api.php
Prepare a message based on parameters; called from drupal_mail().

... See full list

File

drupal/core/modules/user/user.module, line 849
Enables the user registration and login system.

Code

function user_format_name($account) {
  $name = !empty($account->name) ? $account->name : config('user.settings')
    ->get('anonymous');
  drupal_alter('user_format_name', $name, $account);
  return $name;
}