function UserHooks::templatePreprocessDefaultVariablesAlter
Implements hook_template_preprocess_default_variables_alter().
See also
File
-
core/
modules/ user/ src/ Hook/ UserHooks.php, line 211
Class
- UserHooks
- Hook implementations for user.
Namespace
Drupal\user\HookCode
public function templatePreprocessDefaultVariablesAlter(&$variables) : void {
$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.