theme_username
- 5 – 6
theme_username($object)
- 7
theme_username($variables)
Format a username.
Parameters
$object
The user object to format, usually returned from user_load().
Return value
A string containing an HTML link to the user's page if the passed object
suggests that this is a site user. Otherwise, only the username is returned.
Related topics
- Themeable functions
- Functions that display HTML, and which can be customized by themes.
Code
5/includes/theme.inc, line 1042
<?php
function theme_username($object) {
if ($object->uid && $object->name) {
if (drupal_strlen($object->name) > 20) {
$name = drupal_substr($object->name, 0, 15) .'...';
}
else {
$name = $object->name;
}
if (user_access('access user profiles')) {
$output = l($name, 'user/'. $object->uid, array('title' => t('View user profile.')));
}
else {
$output = check_plain($name);
}
}
else if ($object->name) {
if ($object->homepage) {
$output = l($object->name, $object->homepage);
}
else {
$output = check_plain($object->name);
}
$output .= ' ('. t('not verified') .')';
}
else {
$output = variable_get('anonymous', t('Anonymous'));
}
return $output;
}
?>