Skip to content

Instantly share code, notes, and snippets.

@vejnoe
Last active January 16, 2017 07:48
Show Gist options
  • Save vejnoe/cca202f237dd135803d04ee81fba4855 to your computer and use it in GitHub Desktop.
Save vejnoe/cca202f237dd135803d04ee81fba4855 to your computer and use it in GitHub Desktop.
Making user mail available in user-profile.tpl.php via template.php – Drupal 7
<?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);
}
?>
@vejnoe
Copy link
Author

vejnoe commented Jan 16, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment