Skip to content

Instantly share code, notes, and snippets.

@fieldoffice
Last active October 31, 2022 17:55
Show Gist options
  • Save fieldoffice/45abc328ae70c10048db93c3dfec2769 to your computer and use it in GitHub Desktop.
Save fieldoffice/45abc328ae70c10048db93c3dfec2769 to your computer and use it in GitHub Desktop.
Formidable Forms Email Validation
add_filter('frm_validate_field_entry', 'my_custom_validation', 10, 3);
function my_custom_validation($errors, $posted_field, $posted_value){
$fieldArray = array(001,002);
$blockArray = array("@mail.co.uk","@hotmail.","@googlemail.","@gmail.","@yandex.","@live.","@yahoo.","@mail.","@chemist.","@coolsite.","@comic.","@fastmail.","@outlook.","@me.","@aol.","@lycos.","@gmx.","@home.","@123-reg.");
if(in_array($posted_field->id, $fieldArray)){
foreach ($blockArray as $blockedValue) {
if (stripos($posted_value, $blockedValue))
{
$errors['field'. $posted_field->id] = 'Please use a business email address. We\'re unable to process orders for @'. explode('@', $posted_value, 2)[1] .' email addresses.';
}
}
}
return $errors;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment