Created
August 3, 2021 17:08
-
-
Save reachkamrul/d78e438e79f9253ec0640d76f9408e37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = 20; | |
$acceptedDomains = ['gmail.com', 'yahoo.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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment