You are here

function _mailchimp_unsubscribe_user in Mailchimp 5

Same name and namespace in other branches
  1. 5.2 mailchimp.module \_mailchimp_unsubscribe_user()
  2. 6.2 mailchimp.module \_mailchimp_unsubscribe_user()
  3. 6 mailchimp.module \_mailchimp_unsubscribe_user()
  4. 7 mailchimp.module \_mailchimp_unsubscribe_user()

Unsubscribe the given user to the given list

2 calls to _mailchimp_unsubscribe_user()
mailchimp_unsubscribe_form_submit in ./mailchimp.module
mailchimp_user in ./mailchimp.module

File

./mailchimp.module, line 725

Code

function _mailchimp_unsubscribe_user($list, $mail, $message = true, $q = NULL) {
  if ($q || ($q = _mailchimp_get_api_object())) {
    if (_mailchimp_is_subscribed($list['id'], $mail, $q)) {
      $success = $q
        ->listUnsubscribe($list['id'], $mail, false);
      if ($message && $success) {
        drupal_set_message(t('You have unsubscribed from %list.', array(
          '%list' => $list['name'],
        )));
      }
    }
  }
  return true;

  //$success; // the mailchim api seems to always return false on unsubscribe operations
}