# "Confirm Email" Field on Checkout

> Adds a second email field to the classic checkout and blocks the order if the two addresses do not match, to cut down on typos.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, checkout, email, validation
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-confirm-email-field/

## Code

```php
add_filter( 'woocommerce_billing_fields', function ( $fields ) {
    $fields['billing_email_confirm'] = array(
        'label'    => 'Confirm email address',
        'type'     => 'email',
        'required' => true,
        'class'    => array( 'form-row-wide' ),
        'priority' => isset( $fields['billing_email']['priority'] ) ? $fields['billing_email']['priority'] + 1 : 111,
        'validate' => array( 'email' ),
    );

    return $fields;
}, 30 );

add_action( 'woocommerce_after_checkout_validation', function ( $data, $errors ) {
    $email   = isset( $data['billing_email'] ) ? strtolower( trim( (string) $data['billing_email'] ) ) : '';
    $confirm = isset( $data['billing_email_confirm'] ) ? strtolower( trim( (string) $data['billing_email_confirm'] ) ) : '';

    if ( array_key_exists( 'billing_email_confirm', $data ) && $email !== $confirm ) {
        $errors->add( 'validation', 'The email addresses do not match.' );
    }
}, 10, 2 );

add_filter( 'woocommerce_checkout_get_value', function ( $value, $input ) {
    if ( 'billing_email_confirm' === $input && null === $value && is_user_logged_in() ) {
        return wp_get_current_user()->user_email;
    }

    return $value;
}, 10, 2 );
```

## Notes

Logged-in customers with an email on file see the field pre-filled.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find ""Confirm Email" Field on Checkout" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
