Prepares variables for user templates.
Default template: user.html.twig.
array $variables: An associative array containing:
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';
}