---
title: Limit Email Domains in Fluent Forms Form Submission
description: "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 domains will be rejected. Here is an example, this…"
url: "https://fluentforms.com/docs/limit-email-domains-in-fluent-forms-form-submission/"
updated: "2023-07-26"
category: Developer Docs
tags:
  - Email Filter
---

# 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 domains will be rejected.

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

```php
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 = ['gmail.com', 'hotmail.com', 'test.com'];
    $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](https://fluentforms.com/docs/fluentform_validate_input_item_input_text/).
