How to manage spammers who always subscribe to your site

Some people prefer investing their time on your website rather than focusing on their business.

You delete their user, but they subscribe over again and again.

So, what to do?

Simple, don’t delete any more the user but add this snippet to your functions.php

 

add_action( 'init',function(){
    $user = wp_get_current_user();
    if( $user && is_object( $user ) && in_array( $user->user_email,array(
            'tristan@miki8.xyz',
            'tristan@miki9.xyz'
        ) ) ){
        ?><blockquote style="background-color:#F1F1F1;padding:10px;border-left-style:solid;border-left-width:2px;border-left-color:#004358,margin-top:30px;margin-bottom:30px"><p>There has been a critical error on your website. Please check your site admin email inbox for instructions.</p></blockquote><?php
        exit;
    }
} );

 

If the user has an email that you include in the array above, will be able to log in, but will see this

They will see a fake fatal error, and that’s it.