You are here

function email_verify_verify_address in Email Verify 7.2

Additional validation for the form to verify the email address.

1 string reference to 'email_verify_verify_address'
email_verify_form_alter in ./email_verify.module
Implements hook_form_alter().

File

./email_verify.module, line 98
Verifies thoroughly that email addresses are correctly entered.

Code

function email_verify_verify_address($form, &$form_state) {
  if (isset($form_state['values']['op']) && isset($form_state['values']['submit']) && $form_state['values']['op'] == $form_state['values']['submit']) {

    // Get the list of fields.
    $fields = email_verify_get_form_fields($form_state['values']['form_id']);
    if (!empty($fields)) {
      foreach ($fields as $field) {
        if (!empty($form_state['values'][$field])) {

          // Get the data from the field.
          if (is_string($form_state['values'][$field])) {

            // Verify the e-mail address.
            $results = email_verify_check($form_state['values'][$field]);
            if (!empty($results['debugging_text'])) {

              // Log and/or display the debugging information.
              email_verify_process_debug_information($results['debugging_text']);
            }

            // Report the error and flag the form field.
            if (!empty($results['verification_message'])) {
              form_set_error($field, $results['verification_message']);
            }
          }
          elseif (is_array($form_state['values'][$field])) {
            foreach ($form_state['values'][$field] as $lang_code) {
              foreach ($lang_code as $value) {
                $address = reset($value);
                if (!empty($address)) {

                  // Verify the e-mail address.
                  $results = email_verify_check($address);
                  if (!empty($results['debugging_text'])) {

                    // Log and/or display the debugging information.
                    email_verify_process_debug_information($results['debugging_text']);
                  }

                  // Report the error and flag the form field.
                  if (!empty($results['verification_message'])) {
                    form_set_error($field, $results['verification_message']);
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}