You are here

function user_format_name in Drupal 8

Format a username.

Parameters

\Drupal\Core\Session\AccountInterface $account: The account object for the user whose name is to be formatted.

Return value

string An unsanitized string with the username to display.

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Use $account->label() or $account->getDisplayName() instead

See also

https://www.drupal.org/node/3050794

1 call to user_format_name()
UserLegacyTest::testUserFormatName in core/modules/user/tests/src/Kernel/UserLegacyTest.php
Tests user_format_name().

File

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

Code

function user_format_name(AccountInterface $account) {
  @trigger_error('user_format_name() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use $account->label() or $account->getDisplayName() instead. See https://www.drupal.org/node/3050794', E_USER_DEPRECATED);
  return $account
    ->getDisplayName();
}