Skip to content

Instantly share code, notes, and snippets.

@fieldoffice
fieldoffice / formidable-email-validation.php
Last active October 31, 2022 17:55
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.';
}