function simplenews_subscriptions_page_form_validate in Simplenews 6.2
Same name and namespace in other branches
- 7.2 includes/simplenews.subscription.inc \simplenews_subscriptions_page_form_validate()
- 7 includes/simplenews.subscription.inc \simplenews_subscriptions_page_form_validate()
FAPI PAGE subscription form_validate.
2 string references to 'simplenews_subscriptions_page_form_validate'
- simplenews_subscriptions_multi_block_form in includes/
simplenews.subscription.inc - FAPI MULTI BLOCK subscription form.
- simplenews_subscriptions_page_form in includes/
simplenews.subscription.inc - FAPI PAGE subscription form.
File
- includes/
simplenews.subscription.inc, line 286 - (Un)subscription and (un)subscription confirmation
Code
function simplenews_subscriptions_page_form_validate($form, &$form_state) {
global $user;
$valid_email = simplenews_valid_email_address($form_state['values']['mail']);
if (!$valid_email) {
form_set_error('mail', t('The email address you supplied is not valid.'));
}
if (isset($user->mail) && $user->mail == $form_state['values']['mail']) {
$account = $user;
}
else {
$account = (object) array(
'mail' => $form_state['values']['mail'],
);
}
$subscription = simplenews_get_subscription($account);
$checked_newsletters = array_filter($form_state['values']['newsletters']);
if (!count($checked_newsletters) && !$subscription->uid) {
form_set_error('newsletters', t('You must select at least one newsletter.'));
}
}