# Block Checkout for Listed Emails and Phone Numbers

> Stops orders from customers on your block list, such as repeat chargeback offenders, matched by email address, email domain or phone number.

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

## Code

```php
$wpide_block_list = array(
    'emails'  => array( 'fraud@example.com' ),     // Full email addresses.
    'domains' => array( 'bad-domain.example' ),    // Email domains.
    'phones'  => array( '+44 7700 900123' ),       // Phone numbers.
);

add_action( 'woocommerce_after_checkout_validation', function ( $data, $errors ) use ( $wpide_block_list ) {
    $email  = strtolower( trim( (string) ( $data['billing_email'] ?? '' ) ) );
    $domain = false !== strpos( $email, '@' ) ? substr( strrchr( $email, '@' ), 1 ) : '';
    $phone  = preg_replace( '/\D/', '', (string) ( $data['billing_phone'] ?? '' ) );
    $phones = array_map( function ( $number ) {
        return preg_replace( '/\D/', '', $number );
    }, $wpide_block_list['phones'] );

    $blocked = in_array( $email, array_map( 'strtolower', $wpide_block_list['emails'] ), true )
        || ( $domain && in_array( $domain, array_map( 'strtolower', $wpide_block_list['domains'] ), true ) )
        || ( strlen( $phone ) > 5 && in_array( $phone, $phones, true ) );

    if ( $blocked ) {
        $errors->add( 'validation', 'Sorry, we are unable to process this order. Please contact us for help.' );
    }
}, 10, 2 );
```

## Notes

Phone numbers are compared by digits only, and the message is deliberately neutral so blocked customers are not told why.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Block Checkout for Listed Emails and Phone Numbers" 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/
