You are here

function name_username_alter in Name Field 7

Implements hook_username_alter().

File

./name.module, line 233
Defines an API for displaying and inputing names.

Code

function name_username_alter(&$name, $account) {

  // Don't alter anonymous users or objects that do not have any user ID.
  if (empty($account->uid)) {
    return;
  }

  // Try and load the realname in case this is a partial user object or
  // another object, such as a node or comment.
  if (!isset($account->realname)) {
    name_username_alter_preload($account);
  }
  if (isset($account->realname) && drupal_strlen($account->realname)) {
    $name = $account->realname;
  }
}