Drupal 检索名字而不是 name/realname?

Drupal retrieve first name instead of name/realname?

如何检索名字而不是名字(原始用户名)或真实姓名,以便我可以在电子邮件模板变量 !username 中使用它?

$variables['!username'] = $params['account']->realname;

http://cgit.drupalcode.org/faq_ask/tree/faq_ask.module?id=be753ca5c5fe51f33c0515999ceb3a4179298da8#n1052

不确定这是否与实名有关,或者可能 'account' 在哪里被定义为某物...?

我为名字创建了一个字段,它被 LDAP 提取以提供实名并具有 令牌 [user:field-first-name].

我能以某种方式从令牌中提取这个吗?

更新 - 使用用户负载的代码:

$account = user_load($expert->uid);
        $params = array(
          'category' => is_object($term)?$term->tid:-1,
          'question' => $node->title,
          'question_details' => $node->detailed_question,
          'nid' => $node->nid,
          'creator' => theme('username', array('account' => user_load($node->uid), 'plain' => TRUE)),
          'account' => $account,
        );

我试过了

$account = user_load($expert->uid);
$first_name = $account->field_first_name['und'][0]['value'];
        $params = array(
          'category' => is_object($term)?$term->tid:-1,
          'question' => $node->title,
          'question_details' => $node->detailed_question,
          'nid' => $node->nid,
          'creator' => theme('username', array('account' => user_load($node->uid), 'plain' => TRUE)),
          'account' => $first_name,

如果您为名字创建了自定义字段并希望使用用户电子邮件访问它,您可以这样做:

$user = user_load_by_mail($mail); 
$first_name = $user->field_first_name['und'][0]['value'];