function UserHooks::userPresave

Implements hook_ENTITY_TYPE_presave() for user entities.

@todo https://www.drupal.org/project/drupal/issues/3112704 Move to \Drupal\user\Entity\User::preSave().

Attributes

#[Hook('user_presave')]

File

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

Class

UserHooks
Hook implementations for user.

Namespace

Drupal\user\Hook

Code

public function userPresave(UserInterface $account) : void {
  $config = \Drupal::config('system.date');
  if ($config->get('timezone.user.configurable') && !$account->getTimeZone() && !$config->get('timezone.user.default')) {
    $account->timezone = $config->get('timezone.default');
  }
}

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