Skip to content

Instantly share code, notes, and snippets.

@aimahdi
Last active September 29, 2023 06:10
Show Gist options
  • Save aimahdi/841ebfb343b6a2f22ed77dcfdbcd1cd2 to your computer and use it in GitHub Desktop.
Save aimahdi/841ebfb343b6a2f22ed77dcfdbcd1cd2 to your computer and use it in GitHub Desktop.
add_filter('fluentform/validate_input_item_input_email', function ($default, $field, $formData, $fields, $form) {
// You may change the following 3 lines
$targetFormId = 101; //change the form id with your own.
$errorMessage = 'Looks like email is not correct, please use a valid email'; // You may change/modify the meessage
$apiKey = 'lYlSwj3Uxt5iGecFTHYdqKC4xBQYaClfsss'; //reoon API key, you should use your own api key
if ($form->id != $targetFormId) {
return $default;
}
$fieldName = $field['name'];
if (empty($formData[$fieldName])) {
return $default;
}
$email = $formData[$fieldName];
$response = wp_remote_get('https://emailverifier.reoon.com/api/v1/verify?email='.$email.'&key='.$apiKey.'&mode=quick');
if(is_wp_error($request)) {
return $default; // request failed so we are skipping validation
}
$body = json_decode($response['body']);
if($body->status == 'valid'){
return $default;
}
return $errorMessage;
}, 10, 5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment