Skip to content

Instantly share code, notes, and snippets.

@gmmedia
Last active February 6, 2023 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmmedia/8f8e47ef3b0d746a8cecb5ad905ec2d6 to your computer and use it in GitHub Desktop.
Save gmmedia/8f8e47ef3b0d746a8cecb5ad905ec2d6 to your computer and use it in GitHub Desktop.
FluentForms - E-Mail Blacklist - All Forms
<?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