You are here

function simplenews_user_login in Simplenews 8.2

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

Implements hook_user_login().

Subscribe user to a newsletter as per registration form.

File

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

Code

function simplenews_user_login(UserInterface $account) {

  // Subscriptions of users that did sign up by themselves have to be
  // activated first at their first login (-> account::access = 0)
  if ($account
    ->getLastAccessedTime() == 0) {
    $subscriber = Subscriber::loadByUid($account
      ->id());
    if ($subscriber) {
      $subscriber
        ->setStatus(FALSE);
      $subscriber
        ->save();
    }
  }
}