function user_template_preprocess_default_variables_alter in Drupal 9
Same name and namespace in other branches
- 8 core/modules/user/user.module \user_template_preprocess_default_variables_alter()
Implements hook_template_preprocess_default_variables_alter().
See also
File
- core/
modules/ user/ user.module, line 352 - Enables the user registration and login system.
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();
}