You are here

function simplenews_subscription_manager_form_validate in Simplenews 6

Same name and namespace in other branches
  1. 5 simplenews.module \simplenews_subscription_manager_form_validate()
1 string reference to 'simplenews_subscription_manager_form_validate'
simplenews_subscription_manager_form in ./simplenews.subscription.inc
Menu callback: Generates the subscription form for users.

File

./simplenews.subscription.inc, line 41
(Un)subscription and (un)subscription confirmation

Code

function simplenews_subscription_manager_form_validate($form, &$form_state) {
  $valid_email = valid_email_address($form_state['values']['mail']);
  if (!$valid_email) {
    form_set_error('mail', t('The email address you supplied is not valid.'));
  }
  $checked_newsletters = array_filter($form_state['values']['newsletters']);
  $account = new stdClass();
  $account->mail = $form_state['values']['mail'];
  if (!count($checked_newsletters) && !simplenews_get_subscription($account)) {
    form_set_error('newsletters', t('You must select at least one newsletter.'));
  }
}