function user_template_preprocess_default_variables_alter

Same name in other branches
  1. 8.9.x core/modules/user/user.module \user_template_preprocess_default_variables_alter()
  2. 10 core/modules/user/user.module \user_template_preprocess_default_variables_alter()
  3. 11.x core/modules/user/user.module \user_template_preprocess_default_variables_alter()

Implements hook_template_preprocess_default_variables_alter().

See also

user_user_login()

user_user_logout()

File

core/modules/user/user.module, line 356

Code

function user_template_preprocess_default_variables_alter(&$variables) {
    $user = \Drupal::currentUser();
    $variables['user'] = clone $user;
    // Remove password and session IDs, since themes should not need nor see them.
    unset($variables['user']->pass, $variables['user']->sid, $variables['user']->ssid);
    $variables['is_admin'] = $user->hasPermission('access administration pages');
    $variables['logged_in'] = $user->isAuthenticated();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.