format_name

Versions
4.6
format_name($object)

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

▾ 27 functions call format_name()

chameleon_comment in themes/chameleon/chameleon.theme
chameleon_node in themes/chameleon/chameleon.theme
comment_admin_edit in modules/comment.module
Menu callback; edit a comment from the administrative interface.
comment_admin_overview in modules/comment.module
Menu callback; present an administrative comment listing.
hook_search in developer/hooks/core.php
Define a custom search routine.
node_admin_nodes in modules/node.module
Generate the content administration overview.
node_revision_overview in modules/node.module
Generate an overview table of older revisions of a node.
node_search in modules/node.module
Implementation of hook_search().
queue_block in modules/queue.module
Implementation of hook_block().
queue_overview in modules/queue.module
Display a page listing the nodes in the submission queue.
statistics_access_log in modules/statistics.module
statistics_node_tracker in modules/statistics.module
statistics_recent_hits in modules/statistics.module
Menu callback; presents the "Recent hits" page.
statistics_top_users in modules/statistics.module
Menu callback; presents the "Top users" page.
theme_comment in modules/comment.module
theme_comment_folded in modules/comment.module
theme_comment_form in modules/comment.module
theme_node in includes/theme.inc
Return a themed node.
theme_profile_profile in modules/profile.module
tracker_page in modules/tracker.module
Menu callback. Prints a listing of active nodes on the site.
user_admin_account in modules/user.module
user_block in modules/user.module
Implementation of hook_block().
watchdog_event in modules/watchdog.module
Menu callback; displays details about a log message.
watchdog_overview in modules/watchdog.module
Menu callback; displays a listing of log messages.
xtemplate_comment in themes/engines/xtemplate/xtemplate.engine
xtemplate_node in themes/engines/xtemplate/xtemplate.engine
_forum_format in modules/forum.module
Formats a topic for display

Code

includes/common.inc, line 871

<?php
function format_name($object) {

  if ($object->uid && $object->name) {
    // Shorten the name when it is too long or it will break many tables.
    if (strlen($object->name) > 20) {
      $name = truncate_utf8($object->name, 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) {
    // Sometimes modules display content composed by people who are
    // not registered members of the site (e.g. mailing list or news
    // aggregator modules). This clause enables modules to display
    // the true author of the content.
    if ($object->homepage) {
      $output = '<a href="'. check_url($object->homepage) .'">'. check_plain($object->name) .'</a>';
    }
    else {
      $output = check_plain($object->name);
    }

    $output .= ' ('. t('not verified') .')';
  }
  else {
    $output = variable_get('anonymous', 'Anonymous');
  }

  return $output;
}
?>
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.