7

Since few days, every several minutes I get on my mailbox information about new user.

I don't know what is the main purpose for that but I assume someone is checking something on my site and it not anything good.

Is it anyhow possible to disable specific domain while user is filling email field? Should I be worried?

enter image description here

  • 3
    You will be better off using a plugin. CM E-Mail Registration Blacklist or User Domain Whitelistor Ban Hammer – Robert hue Jun 19 '15 at 9:45
  • No need. It's not really an answer. But I would be interested, if someone post a simpler function for this. – Robert hue Jun 19 '15 at 9:48
9

BTW you can try this one. I just put together something. It should block gmail.com domain.

This function will check for email domain when someone tries to register on your website and throws an error if email domain is matched.

function wpse_disable_email_domain( $errors, $sanitized_user_login, $user_email ) {

    list( $email_user, $email_domain ) = explode( '@', $user_email );

    if ( $email_domain == 'gmail.com' ) {
        $errors->add( 'email_error', __( '<strong>ERROR</strong>: Domain not allowed.', 'my_textdomain' ) );
    }

    return $errors;

}

add_filter( 'registration_errors', 'wpse_disable_email_domain', 10, 3 );

OK I just tested it and it's working.

  • I'm sorry but where coul I store this metod? In general-template? – deadfish Jun 19 '15 at 12:08
  • 2
    Yes, in your theme's functions.php file. Just add it at bottom of the file. Make sure to change gmail.com in this function with the domain name you want to block. – Robert hue Jun 19 '15 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.