1 user.theme.inc template_preprocess_user_profile(&$variables)

Process variables for user-profile.tpl.php.

The $variables array contains the following arguments:

  • $account

See also

user-profile.tpl.php

File

core/modules/user/user.theme.inc, line 372
Theme functions for the User module.

Code

function template_preprocess_user_profile(&$variables) {
  $view_mode = $variables['view_mode'] = $variables['elements']['#view_mode'];
  $account = $variables['elements']['#account'];

  // Helpful $user_profile variable for templates.
  foreach (element_children($variables['elements']) as $key) {
    $variables['user_profile'][$key] = $variables['elements'][$key];
  }

  // Preprocess fields.
  field_attach_preprocess('user', $account, $variables['elements'], $variables);

  // Add extra theme hook suggestions for user view_mode and id.
  $variables['theme_hook_suggestions'][] = 'user_profile__' . $view_mode;
  $variables['theme_hook_suggestions'][] = 'user_profile__' . $account->uid;
  $variables['theme_hook_suggestions'][] = 'user_profile__' . $account->uid . '__' . $view_mode;
}