Whitelisting email helps to prevent junk/spam email addresses to submit the form. Only trusted domains can be allowed to submit the form. Whitelisting leads to improved deliverability.
Now, in order to enable this feature, you need to go to the email field options in your form builder.
Here, on the left, you can see the field options for the email field. Scroll down the options to find ‘Advanced Settings’. Now, inside this setting. you will find the section called ‘Whitelisted Domains’. There are two options available in the whitelisted domain section. They are:
- Allowed Domains: When you select this option, you can enter the domain names for example, gmail.com, etc, and the users who enter these domains on the email address fields will only be able to submit the form.
- Denied Domains: When you select this option, you can enter the domain names for example, gmail.com, etc, and submitting the form with these email addresses will be restricted.
When you choose Allowed Domains, the domain listed below this option will be allowed. You will have to add domains seperately for Denied Domain by choosing the Denied Domains option
What happens when a user tries to enter a domain name that is not allowed?
Whenever a domain name that is not allowed is entered in the email field, the form is not submitted and throws an error just like in the image below.
Block a particular Email Address #
If you want to block a particular email address, you will need to add the following code to your theme’s functions.php file.
add_action('everest_forms_process_validate_email', 'email_validate', 10, 3);
function email_validate($field_id, $field_submit, $form_data)
{
if (is_array($field_submit) ) {
$value = ! empty($field_submit['primary']) ? $field_submit['primary'] : '';
} else {
$value = ! empty($field_submit) ? $field_submit : '';
}
$block_email = array('[email protected]', '[email protected]');
if (in_array($value, $block_email, true)) {
evf()->task->errors[ $form_data['id'] ][ $field_id ] = ('Sorry you cannot submit the form');
update_option('evf_validation_error', 'yes');
}
}
Check this out to add custom code on your website.