function mailchimp_unsubscribe_form_validate in Mailchimp 7
Same name and namespace in other branches
- 5.2 mailchimp.module \mailchimp_unsubscribe_form_validate()
- 5 mailchimp.module \mailchimp_unsubscribe_form_validate()
- 6 mailchimp.module \mailchimp_unsubscribe_form_validate()
validate unsubscribe form
_state
Parameters
<type> $form:
File
- ./
mailchimp.module, line 740 - Mailchimp module.
Code
function mailchimp_unsubscribe_form_validate($form, &$form_state) {
if (!$form_state['values']['EMAIL']) {
form_set_error('EMAIL', t('Please enter your email address.'));
}
else {
if ($q = _mailchimp_get_api_object()) {
$subscribed = FALSE;
foreach ((array) $q
->lists() as $list) {
$subscribed = $subscribed || _mailchimp_is_subscribed($list['id'], $form_state['values']['EMAIL'], $q);
}
if (!$subscribed) {
form_set_error('', t('That email address could not be found.'));
}
}
else {
form_set_error('', t('There was an error processing your request. Please try again later.'));
}
}
}