How to Add Domains to the Email Suggestion List

Would you like to add domain names to the email suggestion list on your form? Using a small PHP snippet, you can easily add your own accepted domain names to appear on this list. In this tutorial, we will show you the PHP needed to expand this suggested list.

Creating the form

To begin, we’ll create a new form and add at least one Email field to the form.

If you need any assistance in creating your form, please review this documentation.

begin by creating your form and adding at least one email address form field to the form.

Below, we have two different snippets. You can of course use both or just choose one or the other.

Just copy any or all of the snippets below and add them to your site. If you need help with how and where to add snippets to your site, please review this tutorial.

Adding a new domain to the list

With the snippet below, domain.com will be added to the list of domains that can appear as a suggested domain.

/**
 * Add a new domain to the email suggestion list
 *
 * @link https://wpforms.com/developers/how-to-add-domains-to-the-email-suggestion-list/
 */

function wpf_dev_mailcheck_domains( $domains ) {

    $domains[] = "domain.com";

    return $domains;
}

add_filter( 'wpforms_mailcheck_domains', 'wpf_dev_mailcheck_domains', 10, 1 );

Using this snippet, you can now add domains to the email suggestion list

Adding a top level domain to the list

With the snippet below, the top-level domain xyz will be added to the list of top-level domains that can appear as a suggested top-level domain. For example you could then suggest [email protected] in your email suggestion using this snippet.

/**
 * Add a top-level domain to the email suggestion list
 *
 * @link https://wpforms.com/developers/how-to-add-domains-to-the-email-suggestion-list/
 */

function wpf_dev_mailcheck_toplevel_domains( $domains ) {

    $domains[] = 'xyz';

    return $domains;
}

add_filter( 'wpforms_mailcheck_toplevel_domains', 'wpf_dev_mailcheck_toplevel_domains', 10, 1 );

A top-level domain (TLD) is the last segment of text in a domain name, such as .com or .net.

And that’s it! You’ve successfully added to the email address suggestion list. Would you like to disable this feature completely? Take a look at our tutorial on How to Disable the Email Suggestion on the Email Form Field.

Reference Filters