You are here

function signup_email_confirm_validate in Signup 6

Same name and namespace in other branches
  1. 6.2 modules/signup_confirm_email/signup_confirm_email.inc \signup_email_confirm_validate()
  2. 7 modules/signup_confirm_email/signup_confirm_email.inc \signup_email_confirm_validate()

Validation callback for the signup form.

1 string reference to 'signup_email_confirm_validate'
signup_confirm_email_alter_signup_form in modules/signup_confirm_email/signup_confirm_email.inc
Alter the signup form to add the e-mail confirmation functionality.

File

modules/signup_confirm_email/signup_confirm_email.inc, line 79
Code to confirm the e-mail during signups. Since this code is only needed when building or submitting the signup form (or editing an existing signup), it all lives in this include file and is only loaded when needed.

Code

function signup_email_confirm_validate($form, $form_state) {
  global $user;
  $error = FALSE;
  if (!empty($form_state['values']['email_address'])) {
    if (!valid_email_address($form_state['values']['email_address'])) {
      form_set_error('email_address', t('Invalid e-mail address'));
    }
    if ($form_state['values']['email_address'] != $user->mail && empty($form_state['values']['email_confirm'])) {
      form_set_error('email_confirm', t('Please confirm that you wish to save this new e-mail address into your user profile.'));
      $error = TRUE;
    }
  }

  // Add a JS setting for if the checkbox has a validation error, in which
  // case we display it, even if the 'E-mail address' field isn't re-edited.
  drupal_add_js(array(
    'signupConfirmEmailCheckboxError' => $error,
  ), 'setting');
}