format_username

Versions
7
format_username($account)

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_username_alter(&$name, $account).

See also

hook_username_alter()

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.

Related topics

▾ 19 functions call format_username()

blog_feed_user in modules/blog/blog.pages.inc
Menu callback; displays an RSS feed containing recent blog entries of a given user.
blog_node_view in modules/blog/blog.module
Implement hook_node_view().
blog_page_user in modules/blog/blog.pages.inc
Menu callback; displays a Drupal page containing recent blog entries of a given user.
blog_user_view in modules/blog/blog.module
Implement hook_user_view().
blog_view in modules/blog/blog.module
Implement hook_view().
contact_mail in modules/contact/contact.module
Implement hook_mail().
contact_personal_form in modules/contact/contact.pages.inc
Form builder; the personal contact form.
contact_site_form in modules/contact/contact.pages.inc
Form builder; the site-wide contact form.
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.
openid_user_identities in modules/openid/openid.pages.inc
Menu callback; Manage OpenID identities for the specified user.
profile_block_view in modules/profile/profile.module
Implement hook_block_view().
statistics_user_tracker in modules/statistics/statistics.pages.inc
template_preprocess_username in includes/theme.inc
Preprocess variables for theme_username().
template_preprocess_user_picture in modules/user/user.module
Process variables for user-picture.tpl.php.
toolbar_build in modules/toolbar/toolbar.module
Build the admin menu as a structured array ready for drupal_render().
tracker_page in modules/tracker/tracker.pages.inc
Menu callback; prints a listing of active nodes on the site.
user_page_title in modules/user/user.module
Menu item title callback - use the user name.
_php_filter_tips in modules/php/php.module
Tips callback for php filter.

Code

includes/common.inc, line 2407

<?php
function format_username($account) {
  $name = !empty($account->name) ? $account->name : variable_get('anonymous', t('Anonymous'));
  drupal_alter('username', $name, $account);
  return $name;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.