FluentForms - E-Mail Blacklist - All Forms
This file contains 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
<?php | |
// FluentForms - E-Mail Blacklist | |
// Need help: https://bloggerpilot.com/en/snippet-fluentforms-email-blacklist/ | |
add_filter('fluentform_validate_input_item_input_email', function ($error, $field, $formData, $fields, $form) { | |
// These listed domains will fail to submit the form | |
$blacklistDomains = ['gmail.com', 'hotmail.com', 'test.com']; | |
// You can edit your error message here | |
$errorMessage = 'The provided email domain is not accepted'; | |
$fieldName = $field['name']; | |
if (empty($formData[$fieldName])) { | |
return $error; | |
} | |
$valueArray = explode('@', $formData[$fieldName]); | |
$inputDomain = array_pop($valueArray); | |
if (in_array($inputDomain, $blacklistDomains)) { | |
return [$errorMessage]; | |
} | |
return $error; | |
}, 10, 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment