You are here

function campaignmonitor_unsubscribe in Campaign Monitor 8

Unsubscribes a member from a CampaignMonitor list.

See also

CampaignMonitor_Lists::unsubscribe()

2 calls to campaignmonitor_unsubscribe()
CampaignMonitorUserSubscriptionForm::submitForm in modules/campaignmonitor_user/src/Form/CampaignMonitorUserSubscriptionForm.php
Form submission handler.
campaignmonitor_user_delete in ./campaignmonitor.module
Implements hook_ENTITY_TYPE_delete.

File

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

Code

function campaignmonitor_unsubscribe($list_id, $email, $delete = FALSE, $goodbye = FALSE, $notify = FALSE) {
  $config = \Drupal::config('campaignmonitor.settings');
  $result = FALSE;
  if (campaignmonitor_is_subscribed($list_id, $email)) {
    if ($config
      ->get('cron')) {
      $result = campaignmonitor_addto_queue('campaignmonitor_unsubscribe_process', [
        'list_id' => $list_id,
        'email' => $email,
        'delete' => $delete,
        'goodbye' => $goodbye,
        'notify' => $notify,
      ]);
    }
    else {
      $result = campaignmonitor_unsubscribe_process($list_id, $email, $delete, $goodbye, $notify);
    }
  }
  return $result;
}