You are here

function mailchimp_unsubscribe in Mailchimp 7.3

Same name and namespace in other branches
  1. 8 mailchimp.module \mailchimp_unsubscribe()
  2. 2.x mailchimp.module \mailchimp_unsubscribe()

Unsubscribe a member from a list.

Parameters

string $list_id: A mailchimp list id.

string $email: Email address to be unsubscribed.

bool $delete: Indicates whether an email should be deleted or just unsubscribed.

bool $goodbye: Indicates whether to send the goodbye email to the email address.

bool $notify: Indicates whether to send the unsubscribe notification email to the address defined in the list email notification settings.

object $mcapi: MailChimp API object if one is already loaded.

bool $allow_async: Set to TRUE to allow asynchronous processing using DrupalQueue.

Return value

bool Indicates whether unsubscribe was successful.

2 calls to mailchimp_unsubscribe()
MailchimpListsTestCase::testUnsubscribe in modules/mailchimp_lists/tests/mailchimp_lists.test
Tests unsubscribing a member from a list.
mailchimp_lists_process_subscribe_form_choices in modules/mailchimp_lists/mailchimp_lists.module
Processor for various list form submissions.

File

./mailchimp.module, line 680
Mailchimp module.

Code

function mailchimp_unsubscribe($list_id, $email, $delete = FALSE, $goodbye = FALSE, $notify = FALSE) {
  $result = FALSE;
  if (mailchimp_is_subscribed($list_id, $email)) {
    if (variable_get('mailchimp_cron', FALSE)) {
      $result = mailchimp_addto_queue('mailchimp_unsubscribe_process', array(
        'list_id' => $list_id,
        'email' => $email,
        'delete' => $delete,
        'goodbye' => $goodbye,
        'notify' => $notify,
      ));
    }
    else {
      $result = mailchimp_unsubscribe_process($list_id, $email, $delete, $goodbye, $notify);
    }
  }
  return $result;
}