You are here

function _campaignmonitor_is_subscribed in Campaign Monitor 6.3

Same name and namespace in other branches
  1. 5.2 campaignmonitor.module \_campaignmonitor_is_subscribed()
  2. 5 campaignmonitor.module \_campaignmonitor_is_subscribed()
  3. 6 campaignmonitor.module \_campaignmonitor_is_subscribed()
  4. 6.2 campaignmonitor.module \_campaignmonitor_is_subscribed()

Check if the e-mail address is registrated as subscribed at campaign monitor for the list ID parameter.

Parameters

string $api_key:

int $list_id:

string $email:

boolean $show_errors:

Return value

boolean, TRUE if e-mail is subscribed and FALSE if not.

2 calls to _campaignmonitor_is_subscribed()
campaignmonitor_subscribe_form in ./campaignmonitor.module
campaignmonitor_user_page_form in includes/campaignmonitor.user_page.inc
Builds a newsletter selection form for the user page.

File

./campaignmonitor.module, line 567
Module that plugs in Campaign Monitor functionality to your Drupal web site. For Campaign Monitor information see: http://www.campaignmonitor.com/

Code

function _campaignmonitor_is_subscribed($api_key, $list_id, $email, $show_errors = FALSE) {
  $retval = FALSE;
  $cm = new CampaignMonitor($api_key, $client_id, $campaign_id, $list_id);
  $result = $cm
    ->subscribersGetIsSubscribed($email, $list_id);
  if (empty($result) || $result['anyType']['Code'] != 0) {
    if (empty($result)) {
      watchdog('campaignmonitor', 'There was a problem with the connection to Campaign Monitor.');
    }
    else {
      watchdog('campaignmonitor', 'Code - %code, Message - %message', array(
        '%code' => $result['anyType']['Code'],
        '%message' => $result['anyType']['Message'],
      ));
    }
    drupal_set_message(CM_ERROR, 'error', FALSE);
    $retval = FALSE;
  }
  elseif ($result['anyType'] == 'False') {
    $retval = FALSE;
  }
  elseif ($result['anyType'] == 'True') {
    $retval = TRUE;
  }
  return $retval;
}