I am trying to customize the user-profile.tpl.php file.

I can access the all custom fields using $user_profile['field_fieldname'], and I can even access the user picture using $user_profile['user_picture'], but I don't know how to get the user email.

3 Answers 3


I solved this by following way.

$account = menu_get_object('user');
$mail = $account->mail;

The email field is part of the $user variable. For the currently logged in user, you can get to it via:

global $user;

and a quick:

drupal_set_message('<pre>' . print_r($user,true) . '</pre>');

will show you all sorts of information that is available.

If you need it for a different user, you need to grab the $node->uid from the node you are looking at and then do a user_load($node->uid) to get to the info...

  • I tried this it didn't work. Nov 29, 2011 at 8:43
  • The user profile template file is not associated with any node.
    – apaderno
    Dec 3, 2011 at 13:55

You do know that Users are fieldable now, so you can add whatever CCK fields you want, like phone number, links, e-mail, etc. Each it's own field type. There's no need to get messy in your template files to customize the user profiles.

  • Yah i know that but I don't want to use custom field for email. Nov 29, 2011 at 8:43
  • Rupesh Pawar just wants to use the email address that is associated with the user object. The user object used by Drupal already contains a property for that, without the need of a CCK field.
    – apaderno
    Dec 3, 2011 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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