【发布时间】:2018-03-22 17:25:53
【问题描述】:
如何检索名字而不是姓名(原始用户名)或实名,以便在电子邮件模板变量 !username 中使用它?
$variables['!username'] = $params['account']->realname;
不确定这是否与实名有关,或者“帐户”在哪里定义...?
我创建了一个 名字的字段,它被 LDAP 拉取以提供实名并具有 token [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,
【问题讨论】: