Skip to content

Instantly share code, notes, and snippets.

@gmmedia
Last active February 6, 2023 12:56
Embed
What would you like to do?
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