function template_preprocess_user

Prepares variables for user templates.

Default template: user.html.twig.

Parameters

array $variables: An associative array containing:

  • account: The user account.

File

drupal/core/modules/user/user.pages.inc, line 181
User page callback file for the user module.

Code

function template_preprocess_user(&$variables) {
  $account = $variables['elements']['#user'];

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

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

  // Set up attributes.
  $variables['attributes']['class'][] = 'profile';
}