function UserHooks::userLogin

Implements hook_user_login().

Attributes

#[Hook('user_login')]

File

core/modules/user/src/Hook/UserHooks.php, line 228

Class

UserHooks
Hook implementations for user.

Namespace

Drupal\user\Hook

Code

public function userLogin(UserInterface $account) : void {
  // Reset default theme variables.
  \Drupal::service('theme.manager')->resetActiveTheme();
  // If the user has a NULL time zone, notify them to set a time zone.
  $config = \Drupal::config('system.date');
  if (!$account->getTimezone() && $config->get('timezone.user.configurable') && $config->get('timezone.user.warn')) {
    \Drupal::messenger()->addStatus($this->t('Configure your <a href=":user-edit">account time zone setting</a>.', [
      ':user-edit' => $account->toUrl('edit-form', [
        'query' => \Drupal::destination()->getAsArray(),
        'fragment' => 'edit-timezone',
      ])
        ->toString(),
    ]));
  }
}

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