Last active
January 16, 2017 07:48
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to https://www.drupal.org/node/1161236#comment-6163514