You are here

function _campaignmonitor_add_subscriber in Campaign Monitor 5.2

Same name and namespace in other branches
  1. 5 campaignmonitor.module \_campaignmonitor_add_subscriber()
  2. 6.3 campaignmonitor.module \_campaignmonitor_add_subscriber()
  3. 6 campaignmonitor.module \_campaignmonitor_add_subscriber()
  4. 6.2 campaignmonitor.module \_campaignmonitor_add_subscriber()
3 calls to _campaignmonitor_add_subscriber()
campaignmonitor_form_submit in ./campaignmonitor.module
campaignmonitor_general_form_submit in ./campaignmonitor.module
campaignmonitor_user_form_submit in ./campaignmonitor.module

File

./campaignmonitor.module, line 408

Code

function _campaignmonitor_add_subscriber($api_key, $list_id, $name, $email, $show_errors = FALSE) {
  $cm = new CampaignMonitor($api_key, $client_id, $campaign_id, $list_id);
  $result = $cm
    ->subscriberAddAndResubscribe($email, $name);
  if ($result['anyType']['Code'] != 0) {
    watchdog('campaignmonitor', 'Code - ' . $result['anyType']['Code'] . ', Message - ' . $result['anyType']['Message'], WATCHDOG_ERROR);
    drupal_set_message("There was an error joining to newsletter.", 'error');
  }
  else {
    drupal_set_message("You have successfully been added.", 'status');
  }
}