You are here

function simplenews_user_presave in Simplenews 8.2

Same name and namespace in other branches
  1. 8 simplenews.module \simplenews_user_presave()
  2. 7.2 simplenews.module \simplenews_user_presave()
  3. 7 simplenews.module \simplenews_user_presave()
  4. 3.x simplenews.module \simplenews_user_presave()

Implements hook_user_presave().

If the user is subscribed, update the subscriber from the account.

New accounts have no ID when this hook is called and instead are handled in simplenews_user_insert.

See also

simplenews_user_insert()

File

./simplenews.module, line 478
Simplenews node handling, sent email, newsletter block and general hooks.

Code

function simplenews_user_presave(UserInterface $account) {

  /** @var \Drupal\simplenews\Entity\Subscriber $subscriber */
  if ($subscriber = Subscriber::loadByUid($account
    ->id())) {
    $subscriber
      ->fillFromAccount($account)
      ->save();
  }
}