You are here

function _accountmenu_get_name_and_realname in Account menu 6

Same name and namespace in other branches
  1. 7 accountmenu.module \_accountmenu_get_name_and_realname()

Retrieve the user's name and realname

Return value

a two-element array, first element is the user login name, the second element is user's real name if the realname module is installed. If not, it is the same as the first element.

2 calls to _accountmenu_get_name_and_realname()
accountmenu_preprocess_block in ./accountmenu.module
Substitue tokens @name and @realname with login name and realname. @realname is same as @name if realname module is not install.
accountmenu_translated_menu_link_alter in ./accountmenu.module
Implements hook_link_alter.

File

./accountmenu.module, line 204
accountmenu.module Provide a dynamic Log in/My account/Log out account menu

Code

function _accountmenu_get_name_and_realname() {
  global $user;

  // initialize elements [0] and [1], the second will be set to real name if the
  // realname module is installed
  $result['@name'] = empty($user->name) ? '' : $user->name;
  if (function_exists('realname_get_user')) {
    $account = realname_get_user($user->uid);

    // initialize realname
    $result['@realname'] = $account->name;
  }
  else {
    $result['@realname'] = $result['@name'];
  }
  drupal_alter('accountmenu_name_realname', $result);
  return $result;
}