hacker, hacking, cyber security

Here is a solution to Block Disposable Email Addresses in WordPress in order to resolve registration spam.

Here is a solution to only allowed selected domains to register on your WordPress website.

// Allow Registration Only from @ email addresses

function is_valid_email_domain($login, $email, $errors ){
$valid_email_domains = array(“gmail.com”,”yahoo.com”,”hotmail.com”);// allowed domains change as needed
$valid = false; // sets default validation to false
foreach( $valid_email_domains as $d ){
$d_length = strlen( $d );
$current_email_domain = strtolower( substr( $email, -($d_length), $d_length));
if( $current_email_domain == strtolower($d) ){
$valid = true;
break;
}
}
// Return error message for invalid domains
if( $valid === false ){

$errors->add(‘domain_whitelist_error’,__( ‘<strong>ERROR</strong>: Registration is only allowed from selected approved domains. If you think you are seeing this in error, please contact us.’ ));
}
}
add_action(‘register_post’, ‘is_valid_email_domain’,10,3 );

Place this code in your theme’s functions file – preferrable in a child theme you created or else you will need to update it with each theme update.
See it in action on this site.

Need some help with WordPress registration spam? Contact us.

Let Town Press Media brings your vision to life with stunning, results-driven website design or digital marketing.
Contact us today to start your project!

more insights

SEO Services Austin SEO Services

Town Press Media can increase the search engine rank and site traffic of any company. The expertise offered by its technical and copywriting staff enables Town Press Media to successfully meet the needs of companies with complex websites in competitive industries.

Read more >

Social Media Marketing Austin

We provide a range of high-value social media consultancy services from content creation to full management through which we help you to achieve tangible results from their social media activities.

Read more >

Pay Per Click Metrics

To practically gauge the success or failure of a pay per click account, advertisers need to understand certain metrics and what they mean. Here is a simplified account on pay

Read more >