You are here

function simplenews_subscription_manager_form_validate in Simplenews 5

Same name and namespace in other branches
  1. 6 simplenews.subscription.inc \simplenews_subscription_manager_form_validate()

Forms API callback; validates the settings form.

File

./simplenews.module, line 1014

Code

function simplenews_subscription_manager_form_validate($form_id, $form_values) {
  $valid_email = valid_email_address($form_values['mail']);
  if (!$valid_email) {
    form_set_error('mail', t('The e-mail address you supplied is not valid.'));
  }
  $checked_newsletters = array_filter($form_values['newsletters']);
  if (!count($checked_newsletters) && !simplenews_get_user_subscription($form_values['mail'])) {
    form_set_error('newsletters', t('You must select at least one newsletter.'));
  }
}