2

On the user account page all feilds are displayed except for the email. I have tried to modify the user-profile.tpl, and added

print $user->mail

but it displays the logged in user and not the account being displayed. Not a big problem since the end users usually only see their own account bit frustrating for admins. I also tried

print render($user_profile['mail']);

but that displays nothing.

2
  • Change to the default drupal theme to test if email gets displayed. – No Sssweat Jan 30 '16 at 20:03
  • Upon further review, email is not in user manage fields. Therefore, you could go with Adrian's answer or use Views to display it. – No Sssweat Jan 31 '16 at 6:21
2

You can implement the following hook in the template.php of your theme:

/**
 * Process variables for user-profile.tpl.php.
 *
 * The $variables array contains the following arguments:
 * - $account
 *
 * @see user-profile.tpl.php
 */

function YOUR_THEME_preprocess_user_profile(&$variables) {
  $account = $variables['elements']['#account'];
  //Add mail to $user_profile variable
  $variables['user_profile']['mail'] = $account->mail;
  // Preprocess fields.
  field_attach_preprocess('user', $account, $variables['elements'], $variables);
}

And in your user-profile.tpl you can use:

print $user_profile['mail'];
2
  • Excellent. Works fine on the page that displays the account info, but the page that edits the data displays errors. Is the email added twice? Warning: Invalid argument supplied for foreach() i element_children() (rad 6540 av /storage/content/88/176188/rme.nu/public_html/includes/common.inc). – Bosse Jan 31 '16 at 13:12
  • @Bosse I don't know try to debug with the devel dpm function – Adrian Cid Almaguer Feb 5 '16 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.