ECommerce is serious business, that is why when a customer signs up to your store you want the most accurate information to stay in touch, promote your products and offer decent after sales service. Unfortunately, there are lots of chancers out there on the internet that use fraudulent cards and fake emails to purchase products from your store, which can leave you to foot the bill.

The following piece of code will prohibit usage of fake emails for creating accounts, it focuses on but can easily be expanded to include other email domains by just adding to the array.

Add the following code to end of your theme’s functions.php file omitting the opening <?php tag

* Do not allow account creation with temp email addresses
* @param Object $validation_errors
* @param string $username
* @param string $email
* @return WP_Error
function do_not_allow_temp_email_addresses( $validation_errors, $username, $email ) {
$prohibitied_domains = array(
$email_domain = explode( '@', $email )[1];
if ( in_array( $email_domain, $prohibitied_domains ) ) {
return new WP_Error( 'registration-error-bad-email', __( 'Please use a valid email address.' ) );
return $validation_errors;
} // End do_not_allow_temp_email_addresses()
add_filter( 'woocommerce_registration_errors', 'do_not_allow_temp_email_addresses', 10, 3 );

view raw


hosted with ❤ by GitHub