You are here

function newsletter_is_subscribed in Newsletter 7

Checks whether an email is registered to newsletter list or not.

Return value

boolean TRUE or FALSE.

3 calls to newsletter_is_subscribed()
NewsletterSubscriberController::save in includes/newsletter.subscriber.controller.inc
newsletter_block_view in ./newsletter.module
Implements hook_block_view().
newsletter_subscribe_form_submit in ./newsletter.module
Callback of newsletter subscription block.Degrades when js is off. Validates e-mail and sends user to next step.

File

./newsletter.module, line 1083
Defines menu items for newsletter administration, permissions and basic drupal hooks.

Code

function newsletter_is_subscribed($mail = NULL) {
  if (!isset($mail)) {
    global $user;
    $mail = isset($user->mail) ? $user->mail : FALSE;
  }
  if ($mail) {
    $is_subscribed = db_query('SELECT email FROM {newsletter_subscriber} WHERE email = :mail', array(
      ':mail' => $mail,
    ))
      ->fetchField();
    return (bool) $is_subscribed;
  }
  else {
    return FALSE;
  }
}