How We Helped a Client Restrict Free Email Addresses in Fluent Forms
At Xenrion, we often receive unique client requests that require custom and thoughtful solutions — and this one was a great example.
One of our clients wanted to restrict all form submissions from free email providers such as Gmail, Yahoo, Hotmail, Outlook, etc., and allow only branded domain emails (e.g., name@company.com) in their website’s contact form.
The client’s goal was simple:
They wanted to ensure that only professional or business users could submit the form — helping them filter out irrelevant or spammy leads.
The Challenge
Fluent Forms (one of our go-to WordPress form plugins) offers a lot of flexibility, but it doesn’t natively support blocking free email addresses.
To achieve this functionality, we referred to the Fluent Forms developer documentation and explored its built-in filters and hooks. This allowed us to implement a custom validation snippet that could perfectly meet the client’s requirement.
The Solution
We created a small custom PHP snippet that validates the email field on submission.
If the email entered belongs to a free email service provider (like gmail.com, hotmail.com, or yahoo.com), the form will show a friendly error message and block the submission.
If it’s a business or branded domain email, the submission goes through successfully.
Below is the snippet we used — you can easily copy and add it to your WordPress theme’s functions.php file or a site-specific plugin.
Code Snippet
add_filter('fluentform/validate_input_item_input_email', function ($error, $field, $formData, $fields, $form) {
/*
* Block common free email providers
* Only business/branded domains will be accepted
*/
$targetFormId = 12;
$blockedDomains = ['gmail.com', 'hotmail.com', 'outlook.com', 'yahoo.com', 'aol.com', 'mail.com', 'protonmail.com', 'icloud.com'];
$errorMessage = 'Please use your business email address. Free email providers (Gmail, Hotmail, Outlook, etc.) are not accepted.';
if ($form->id != $targetFormId) {
return $error;
}
$fieldName = $field['name'];
if (empty($formData[$fieldName])) {
return $error;
}
$valueArray = explode('@', $formData[$fieldName]);
$inputDomain = strtolower(array_pop($valueArray));
if (in_array($inputDomain, $blockedDomains)) {
return [$errorMessage];
}
return $error;
}, 10, 5);
How It Works
- The snippet hooks into Fluent Form’s
fluentform_validate_input_item_input_emailfilter. - It captures the submitted email address and extracts the domain after “@”.
- The domain is compared against a predefined list of free email providers.
- If a match is found, an error message appears and submission is stopped.
This lightweight customization helped our client maintain lead quality and ensure that only authentic business users contacted them.
Final Thoughts
At Xenrion, we specialize in creating tailored solutions that enhance WordPress functionality and user experience. Whether it’s form validation, automation, or custom integrations — our goal is to make every website smarter and more efficient.
If you’d like to implement similar functionality or have a specific form requirement, get in touch with our team — we’d be happy to help you build it right.
