На сайте есть пользователи и у них есть возможность просматривать аккаунты друг друга. Как вывести почту, указанную при регистрации ?
Как реализовать поле mail при просмотре аккаунтов
Главные вкладки
Лучший ответ
1
можно API покурить:
В template.php
<?php
/**
* Process variables for user-profile.tpl.php.
*
* The $variables array contains the following arguments:
* - $account
*
* @see user-profile.tpl.php
*/
function YOUR_THEMENAME_preprocess_user_profile(&$variables) {
$account = $variables['elements']['#account'];
// Helpful $user_profile variable for templates.
foreach (element_children($variables['elements']) as $key) {
$variables['user_profile'][$key] = $variables['elements'][$key];
}
//Add mail to $user_profile variable
$variables['user_profile']['mail'] = $account->mail;
// Preprocess fields.
field_attach_preprocess('user', $account, $variables['elements'], $variables);
}
?>
Далее - выводим $user_profile['mail'] в своем user-profile.tpl.php
Комментарии
profile2 удобней всего использовать
Как это реализовать, пока что не могу найти ?
Чем views не устраивает?
можно API покурить:
В template.php
<?php
/**
* Process variables for user-profile.tpl.php.
*
* The $variables array contains the following arguments:
* - $account
*
* @see user-profile.tpl.php
*/
function YOUR_THEMENAME_preprocess_user_profile(&$variables) {
$account = $variables['elements']['#account'];
// Helpful $user_profile variable for templates.
foreach (element_children($variables['elements']) as $key) {
$variables['user_profile'][$key] = $variables['elements'][$key];
}
//Add mail to $user_profile variable
$variables['user_profile']['mail'] = $account->mail;
// Preprocess fields.
field_attach_preprocess('user', $account, $variables['elements'], $variables);
}
?>
Далее - выводим $user_profile['mail'] в своем user-profile.tpl.php
Спасибо большое! Неделю искал.