user_template_preprocess_default_variables_alter

user_template_preprocess_default_variables_alter(&$variables)

Implements hook_template_preprocess_default_variables_alter().

See also

user_user_login()

user_user_logout()

File

core/modules/user/user.module, line 435
Enables the user registration and login system.

Code

1
2
3
4
5
6
7
8
9
10
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();
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.