Limit Email Domains in Fluent Forms Form Submission

If you want to stop some specific email domains from a form submission, you can do this using the email filter hook fluentform_validate_input_item_input_email. Just add the accepted email domain, other email domain will be rejected.

Here is an example , this will be applied to form ID of 12.

add_filter('fluentform_validate_input_item_input_email', function ($error, $field, $formData, $fields, $form) {
     * add your accepted domains here
     * Other domains will be failed to submit the form
    $targetFormId = 12;
    $acceptedDomains = ['', '', ''];
    $errorMessage = 'The provided email domain is not accepted';

    if ($form->id != $targetFormId) {
        return $error;

    $fieldName = $field['name'];
    if (empty($formData[$fieldName])) {
        return $error;

    $valueArray = explode('@', $formData[$fieldName]);
    $inputDomain = array_pop($valueArray);

    if (!in_array($inputDomain, $acceptedDomains)) {
        return [$errorMessage];
    return $error;

}, 10, 5);

For details of the hook fluentform_validate_input_item_input_email check this documentation link.

Powered by BetterDocs

Leave a Reply

Your email address will not be published. Required fields are marked *