You are here

function user_user_login in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/user/user.module \user_user_login()

Implements hook_user_login().

File

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

Code

function user_user_login(UserInterface $account) {

  // Reset static cache of default variables in template_preprocess() to reflect
  // the new user.
  drupal_static_reset('template_preprocess');

  // 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(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(),
    ]));
  }
}