You are here

function mailchimp_unsubscribe_form_submit in Mailchimp 6.2

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

submit handler for unsubscribe form

_state

Parameters

<type> $form:

File

./mailchimp.module, line 807
Mailchimp module.

Code

function mailchimp_unsubscribe_form_submit($form, &$form_state) {
  if ($q = _mailchimp_get_api_object()) {
    $success = FALSE;
    $count = 0;
    global $user;
    foreach ((array) _mailchimp_get_available_lists($user) as $list) {
      $success = _mailchimp_unsubscribe_user($list, $form_state['values']['EMAIL'], FALSE, $q);
      if ($success) {
        $count++;
        drupal_set_message(t('Thank you, you have been successfully unsubscribed from !list.', array(
          '!list' => '<em>' . $list->name . '</em>',
        )));
      }
    }
    if ($count == 0) {
      drupal_set_message(t('There were no lists to unsubscribe from at this time.'));
    }
  }
}