Skip to content

Instantly share code, notes, and snippets.

@aimahdi
Last active March 10, 2025 06:01
Show Gist options
  • Save aimahdi/5933aee5d138f4d0f895454f109c980d to your computer and use it in GitHub Desktop.
Save aimahdi/5933aee5d138f4d0f895454f109c980d to your computer and use it in GitHub Desktop.
validate_email_exclude_business.php
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