You are here

function mailchimp_subscribe_anon_form_submit in Mailchimp 7

Same name and namespace in other branches
  1. 6.2 mailchimp.module \mailchimp_subscribe_anon_form_submit()

Submit handler for anonymous subscription form

Parameters

<type> $form_state:

<type> $q - MC API object:

1 string reference to 'mailchimp_subscribe_anon_form_submit'
mailchimp_subscribe_anon_form_all in ./mailchimp.module
Return a form for all available MC lists

File

./mailchimp.module, line 527
Mailchimp module.

Code

function mailchimp_subscribe_anon_form_submit($form, &$form_state) {
  $lists = $form_state['values']['mailchimp_lists'];
  foreach ($lists as $list) {
    if (!empty($list['EMAIL'])) {
      $success = FALSE;

      // filter our interest groups and return in an comma delimited string
      if (!empty($list['INTERESTS'])) {
        $list['INTERESTS'] = implode(',', array_filter($list['INTERESTS']));
      }
      $success = _mailchimp_subscribe_user($list['list'], $list['EMAIL'], $list, TRUE);
      if ($success) {
        $msg = variable_get('mailchimp_subscription_success_message', t('Thank you, you have been successfully subscribed.'));
      }
      else {
        $msg = variable_get('mailchimp_subscription_failure_message', t('We were unable to subscribe you at this time. Please try again later.'));
      }
      drupal_set_message($msg);
    }
  }
}