function format_username

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

17 calls to format_username()
hook_mail in modules/system/system.api.php
Prepare a message based on parameters; called from drupal_mail().
hook_user_view in modules/user/user.api.php
The user's account information is being displayed.
NodeTokenReplaceTestCase::testNodeTokenReplacement in modules/node/node.test
Creates a node, then tests the tokens generated from it.
node_feed in modules/node/node.module
Generates and prints an RSS feed.
node_tokens in modules/node/node.tokens.inc
Implements hook_tokens().

... See full list

1 string reference to 'format_username'
user_entity_info in modules/user/user.module
Implements hook_entity_info().

File

includes/common.inc, line 2225

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.