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.
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.