Last active
March 10, 2025 06:01
-
-
Save aimahdi/5933aee5d138f4d0f895454f109c980d to your computer and use it in GitHub Desktop.
validate_email_exclude_business.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('fluentform/validate_input_item_input_email', function ($errorMessage, $field, $formData, $fields, $form) { | |
$targetFormId = 15; | |
if ($form->id != $targetFormId) { | |
return $errorMessage; | |
} | |
$fieldName = $field['name']; | |
if (empty($formData[$fieldName])) { | |
return 'Please enter an email'; | |
} | |
$value = $formData[$fieldName]; | |
$regexPattern = "/^(?!.*@(gmail|yahoo|hotmail|outlook|aol|icloud|live|msn|protonmail|zoho|mail|yandex).).+@.+..+$/i"; | |
if (!preg_match($regexPattern, $value)) { | |
return "Please enter a business email address"; | |
} | |
return $errorMessage; | |
}, 10, 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment