Blocking user registration by country level domain in WordPress

15 thoughts on “Blocking user registration by country level domain in WordPress”

  1. Hey, I think your blog might be having browser compatibility issues.
    When I look at your blog in Chrome, it looks fine but when opening in Internet Explorer, it has some overlapping.

    I just wanted to give you a quick heads up! Other then that, excellent blog!

  2. Doesn’t work at all….. pasted the code into my child theme’s functions.php and it Just locks up the entire web site and the pages don’t get served…. Don’t know what the error is, but it’s clear that there is one in the above code.

      1. No not at all… I just checked what is in my functions.php against what is shown above in your source code and it matches exactly, no additional or incorrect characters at all. It just won’t work. Something not right with it somewhere. But I’m not sure what it is. here is exactly what is in my functions.php file.
        *****************************************************************************

        function wedevs_block_user_registration_by_email( $errors ) {
        $email = $_POST[‘user_email’];
        $ext = substr( strrchr( $email, ‘.’ ), 1 ); // get last part of dot in email
        $blocked_domains = array( ‘pl’ );

        if ( in_array( $ext, $blocked_domains ) ) {
        $errors->add( ’email_blocked’, __( ‘You are blocked from registration.’, ‘dlp’ ) );
        }

        return $errors;
        }

        add_filter( ‘registration_errors’, ‘wedevs_block_user_registration_by_email’ );

        ********************************************************************************

        If you can see any error in that please do let me know. I can’t see anything obvious.

        1. not sure how much this matters but I noticed that your ‘ symbol is different then the ‘ symbol above in the sample code at the top of page (which worked okay in our blog)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.