function format_username

format_username($account)

Format a username.

This is also the label callback implementation of callback_entity_info_label() for user_entity_info().

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_username_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_username_alter()

Related topics

File

includes/common.inc, line 2154
Common functions that many Drupal modules will need to reference.

Code

function format_username($account) {
  $name = !empty($account->name) ? $account->name : variable_get('anonymous', t('Anonymous'));
  drupal_alter('username', $name, $account);
  return $name;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!common.inc/function/format_username/7.x