Key Takeaways

  • WordPress powers a large share of the web, so adding email verification to its registration and WooCommerce checkout forms blocks a huge volume of bad data.
  • The right place to verify is a server-side PHP hook that fires before the account or order is created, so invalid and disposable addresses never get saved.
  • Use the registration_errors filter for WordPress signups and the woocommerce_checkout_process action for WooCommerce, calling the API with wp_remote_get.
  • Store the API key in wp-config.php, not in the database or theme files, and fail open on a timeout so a verification outage never blocks real checkouts.

WordPress runs a large share of all websites, and WooCommerce powers a huge number of online stores, which means a great deal of the world's signup and checkout data flows through their forms. It also means most fake registrations, disposable-email trial abuse, and checkout typos enter through exactly these two forms. Email verification in WordPress and WooCommerce stops that bad data at the source with a few lines of PHP. This guide adds verification to both the registration and checkout flows using the correct hooks and the v2 API. For the broader PHP patterns, see the verify email with PHP integration page.

The key principle is to verify server-side, inside a hook that runs before the record is created, so a bad address is rejected rather than stored.

Store the API Key Safely

Before any code, add your API key to wp-config.php as a constant, above the line that says to stop editing. This keeps the key out of the database and out of theme files, so it is not exposed if those are compromised or shared.

// wp-config.php
define( 'EMAILVERIFIER_API_KEY', 'YOUR_API_KEY' );

A Shared Verification Helper

Both hooks will call the same helper, which makes the request with wp_remote_get, WordPress's built-in HTTP function, and returns a simple decision. Put this in a small plugin file or your theme's functions.php.

<?php
/**
 * Returns 'accept', 'reject', or 'unknown' for an email address.
 * Fails open ('accept') on any API or network error.
 */
function ev_verify_email( $email ) {
    $url = add_query_arg(
        array(
            'api_key' => EMAILVERIFIER_API_KEY,
            'email'   => $email,
        ),
        'https://emailverifierapi.com/v2/verify'
    );

    $res = wp_remote_get( $url, array( 'timeout' => 4 ) );
    if ( is_wp_error( $res ) ) {
        return 'accept'; // never block a real user on an outage
    }

    $code = wp_remote_retrieve_response_code( $res );
    if ( 200 !== $code ) {
        return 'accept';
    }

    $data = json_decode( wp_remote_retrieve_body( $res ), true );
    if ( 'failed' === $data['status'] || ! empty( $data['isDisposable'] ) ) {
        return 'reject';
    }
    if ( 'passed' === $data['status'] ) {
        return 'accept';
    }
    return 'unknown';
}

The most important design choice here is to fail open. If the API times out or returns an error, the helper returns accept, so a verification problem never blocks a real customer from registering or checking out. You protect against bad data without ever risking a lost sale to an outage.

Important Always fail open on checkout verification. Blocking a paying customer because the verification call timed out costs you a real order, which is far worse than letting one unverified address through. Reject only on a definitive failed or disposable result.

Hook 1: WordPress Registration

The registration_errors filter runs when a user submits the WordPress signup form, before the account is created. Add an error to the object to block the registration and show the user a message.

add_filter( 'registration_errors', 'ev_registration_check', 10, 3 );

function ev_registration_check( $errors, $login, $email ) {
    if ( empty( $email ) ) {
        return $errors;
    }
    if ( 'reject' === ev_verify_email( $email ) ) {
        $errors->add(
            'ev_bad_email',
            __( 'Please use a valid, non-disposable email address.' )
        );
    }
    return $errors;
}

Hook 2: WooCommerce Checkout

For WooCommerce, the woocommerce_checkout_process action runs when the customer submits the checkout, before the order is placed. Use wc_add_notice to block the order and show the message.

add_action( 'woocommerce_checkout_process', 'ev_checkout_check' );

function ev_checkout_check() {
    $email = isset( $_POST['billing_email'] )
        ? sanitize_email( wp_unslash( $_POST['billing_email'] ) )
        : '';

    if ( $email && 'reject' === ev_verify_email( $email ) ) {
        wc_add_notice(
            __( 'Please enter a valid email so we can send your receipt and order updates.' ),
            'error'
        );
    }
}

Now a disposable or invalid address is caught at both the registration form and the checkout, with a clear message prompting the customer to fix it. The order receipt and account email have a real inbox to reach, which is exactly what you want for a store that depends on order confirmations and shipping updates.

Verify in the hook that runs before the account or order is saved, so bad data never enters the database. Source: WordPress and WooCommerce validation best practice, 2026
Pro Tip Cache verification results for a short window using the WordPress Transients API, keyed on the email. If a customer re-submits after fixing another field, you avoid a second API call for the same address, which saves credits on busy checkout pages.

New developers can grab 100 free email verification credits to test both hooks on a staging site, and the email verification API documentation covers the full response schema so you can extend the logic to flag role accounts or catch-all domains.

Frequently Asked Questions

How do I add email verification to WordPress registration?

Use the registration_errors filter, which runs before the account is created. Call your verification helper inside it, and if the address is invalid or disposable, add an error to the errors object to block the signup and show a message. This stops bad addresses from ever becoming WordPress accounts.

Which hook should I use for WooCommerce checkout verification?

Use the woocommerce_checkout_process action, which runs when the customer submits checkout but before the order is placed. Call your verification helper with the billing_email, and use wc_add_notice with the error type to block the order and prompt a correction if the address fails. Always fail open on an API error so a timeout never blocks a paying customer.

Where should I store my API key in WordPress?

In wp-config.php as a defined constant, not in the database, a plugin setting, or theme files. wp-config.php sits outside the web-accessible content and is the standard place for secrets in WordPress, so the key is not exposed if the database is dumped or theme files are shared.

Will adding verification slow down my checkout?

Minimally. The verification call completes in roughly 600 milliseconds, and it runs server-side during form processing, which users already expect to take a moment. Setting a short timeout and failing open means that even if the API is slow, the checkout proceeds rather than stalling, so there is no risk of blocking a sale.