function format_username
7.x common.inc | 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
Related topics
30 calls to format_username()
- BlogTestCase::testBlogPageNoEntries in drupal-7.x/
modules/ blog/ blog.test - View the blog of a user with no blog entries as another user.
- BlogTestCase::testUnprivilegedUser in drupal-7.x/
modules/ blog/ blog.test - Confirm that the "You are not allowed to post a new blog entry." message shows up if a user submitted blog entries, has been denied that permission, and goes to the blog page.
- BlogTestCase::verifyBlogLinks in drupal-7.x/
modules/ blog/ blog.test - Verify the blog links are displayed to the logged in user.
- BlogTestCase::verifyBlogs in drupal-7.x/
modules/ blog/ blog.test - Verify the logged in user has the desired access to the various blog nodes.
- blog_feed_user in drupal-7.x/
modules/ blog/ blog.pages.inc - Menu callback; displays an RSS feed containing recent blog entries of a given user.
1 string reference to 'format_username'
- user_entity_info in drupal-7.x/
modules/ user/ user.module - Implements hook_entity_info().
File
- drupal-7.x/
includes/ common.inc, line 2106 - 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;
}