You are here

protected function SubscriptionManager::requiresConfirmation in Simplenews 8.2

Same name and namespace in other branches
  1. 8 src/Subscription/SubscriptionManager.php \Drupal\simplenews\Subscription\SubscriptionManager::requiresConfirmation()
  2. 3.x src/Subscription/SubscriptionManager.php \Drupal\simplenews\Subscription\SubscriptionManager::requiresConfirmation()

Checks whether confirmation is required for this newsletter and user.

Parameters

\Drupal\simplenews\NewsletterInterface $newsletter: The newsletter entity.

int $uid: The user ID that belongs to the email.

Return value

bool TRUE if confirmation is required, FALSE if not.

2 calls to SubscriptionManager::requiresConfirmation()
SubscriptionManager::subscribe in src/Subscription/SubscriptionManager.php
Subscribe a user to a newsletter or send a confirmation mail.
SubscriptionManager::unsubscribe in src/Subscription/SubscriptionManager.php
Unsubscribe a user from a mailing list or send a confirmation mail.

File

src/Subscription/SubscriptionManager.php, line 319

Class

SubscriptionManager
Default subscription manager.

Namespace

Drupal\simplenews\Subscription

Code

protected function requiresConfirmation(NewsletterInterface $newsletter, $uid) {

  // If user is currently logged in, don't send confirmation.
  // Other addresses receive a confirmation if double opt-in is selected.
  if ($this->currentUser
    ->id() && $uid && $this->currentUser
    ->id() == $uid) {
    return FALSE;
  }
  else {
    return $newsletter->opt_inout == 'double';
  }
}