在Drupal 6中,如果我们想了解有关配置文件用户的所有信息,我们会打印$ account变量。但是,我刚刚在Drupal 7中发现,$ account变量不再可用。访问个人资料用户帐户信息的新方法是什么?
答案 0 :(得分:4)
试试这个:print_r($elements['#account']);
当我把它放在user-profile.tpl.php中时,我得到一个像......这样的对象。
stdClass Object
(
[uid] => 29
[name] => user
[pass] =>
[mail] => user@example.com
[theme] =>
[signature] =>
[signature_format] =>
[created] => 1304866465
[access] => 0
[login] => 0
[status] => 1
[timezone] =>
[language] =>
[picture] =>
[init] =>
[data] =>
[roles] => Array
(
[2] => authenticated user
)
[entity_view_prepared] => 1
)
(我通过安装Devel模块并通过将dsm(get_defined_vars());
放入模板来检查可用变量来找到这一点。)