function email_verify_form_validate in Email Verify 8.2
Additional validation for forms.
Parameters
array $form: The form definition.
array $form_state: The form values which you may perform validation on.
1 string reference to 'email_verify_form_validate'
- email_verify_form_alter in ./
email_verify.module - Implements hook_form_alter().
File
- ./
email_verify.module, line 63 - Verifies thoroughly that email addresses are correctly entered.
Code
function email_verify_form_validate($form, &$form_state) {
if (!\Drupal::currentUser()
->hasPermission('bypass email verification') && $form_state
->getValue('op')
->getUntranslatedString() != 'Cancel account') {
$email = $form_state
->getValue('mail');
$host = Unicode::substr(strstr($email, '@'), 1);
$manager = \Drupal::getContainer()
->get('email_verify.manager');
$manager
->checkHost($host);
// Only check full emails if the host can connect out on port 25.
if (\Drupal::config('email_verify.settings')
->get('active')) {
$manager
->checkEmail($email);
}
if ($errors = $manager
->getErrors()) {
foreach ($errors as $error) {
$form_state
->setErrorByName('mail', $error);
}
}
}
}