function mailchimp_subscribe_form_submit in Mailchimp 5
Same name and namespace in other branches
- 5.2 mailchimp.module \mailchimp_subscribe_form_submit()
- 6 mailchimp.module \mailchimp_subscribe_form_submit()
File
- ./
mailchimp.module, line 494
Code
function mailchimp_subscribe_form_submit($form_id, $form_values) {
global $user;
if ($q = _mailchimp_get_api_object()) {
$lists = _mailchimp_get_available_lists($user, $q);
$success = true;
foreach ($lists as $list) {
$lid = $list['id'];
$sub_info = $q
->listMemberInfo($lid, $form_values['list_' . $lid]['EMAIL']);
$is_subscribed = @$sub_info['status'] == 'subscribed';
// add users who are not subscribed and checked the list
if ($form_values['list_' . $list['id']][$lid] && !$is_subscribed) {
$success = $success && _mailchimp_subscribe_user($list, $form_values['list_' . $list['id']], true, $q);
}
}
drupal_goto('mailchimp/subscribe/message', 'success=' . $success);
}
}