You are here

function mailchimp_unsubscribe_form_submit in Mailchimp 5

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

File

./mailchimp.module, line 540

Code

function mailchimp_unsubscribe_form_submit($form_values = array()) {
  if ($q || ($q = _mailchimp_get_api_object())) {
    $success = true;
    foreach ((array) $q
      ->lists() as $list) {
      $success = $success && _mailchimp_unsubscribe_user($list, $form['EMAIL'], true, $q);
      if ($success) {
        drupal_set_message(variable_get('mailchimp_unsubscription_success_message', SUBSCRIPTION_SUCCESS));
      }
      else {
        drupal_set_message(variable_get('mailchimp_unsubscription_failure_message', SUBSCRIPTION_SUCCESS));
      }
    }
  }
}