Hi.
I wonder whether you have plans to add Fluent Forms integration? Looking at how FF integrate with truemail.io it shouldn’t be too difficult to achieve. Here’s FF code:
add_filter('fluentform_validate_input_item_input_email', function ($default, $field, $formData, $fields, $form) {
// You may change the following 3 lines
$targetFormId = 12;
$errorMessage = 'Looks like email is not correct'; // You may change here
$trueMailApiKey = 'INSERT_YOUR_TRUEMAIL.IO_API_KEY';
if ($form->id != $targetFormId) {
return $default;
}
$fieldName = $field['name'];
if (empty($formData[$fieldName])) {
return $default;
}
$email = $formData[$fieldName];
$request = wp_remote_get('https://truemail.io/api/v1/verify/single? address_info=1&timeout=5&access_token='.$trueMailApiKey.'&email='.$email);
if(is_wp_error($request)) {
return $default; // request failed so we are skipping validation
}
$response = wp_remote_retrieve_body($request);
$response = json_decode($response, true);
if($response['result'] == 'valid') {
return $default;
}
return $errorMessage;
}, 10, 5);
Hope this can be done. Thanks!
]]>