function theme_username in Drupal 7
Same name and namespace in other branches
- 4 includes/theme.inc \theme_username()
- 5 includes/theme.inc \theme_username()
- 6 includes/theme.inc \theme_username()
Returns HTML for a username, potentially linked to the user's page.
Parameters
$variables: An associative array containing:
- account: The user object to format.
- name: The user's name, sanitized.
- extra: Additional text to append to the user's name, sanitized.
- link_path: The path or URL of the user's profile page, home page, or other desired page to link to for more information about the user.
- link_options: An array of options to pass to the l() function's $options parameter if linking the user's name to the user's page.
- attributes_array: An array of attributes to pass to the drupal_attributes() function if not linking to the user's page.
See also
template_preprocess_username()
Related topics
23 theme calls to theme_username()
- blog_page_user in modules/
blog/ blog.pages.inc - Menu callback; displays a Drupal page containing recent blog entries of a given user.
- comment_admin_overview in modules/
comment/ comment.admin.inc - Form builder for the comment overview administration form.
- comment_form in modules/
comment/ comment.module - Generate the basic commenting form, for appending to a node or display on a separate page.
- contact_personal_form in modules/
contact/ contact.pages.inc - Form constructor for the personal contact form.
- dblog_event in modules/
dblog/ dblog.admin.inc - Page callback: Displays details about a specific database log message.
File
- includes/
theme.inc, line 2367 - The theme system, which controls the output of Drupal.
Code
function theme_username($variables) {
if (isset($variables['link_path'])) {
// We have a link path, so we should generate a link using l().
// Additional classes may be added as array elements like
// $variables['link_options']['attributes']['class'][] = 'myclass';
$output = l($variables['name'] . $variables['extra'], $variables['link_path'], $variables['link_options']);
}
else {
// Modules may have added important attributes so they must be included
// in the output. Additional classes may be added as array elements like
// $variables['attributes_array']['class'][] = 'myclass';
$output = '<span' . drupal_attributes($variables['attributes_array']) . '>' . $variables['name'] . $variables['extra'] . '</span>';
}
return $output;
}