• Hi,I need your help. I have made an WordPress site. Now I want to apply some condition on user registration system. Is it possible to do the user registration only for selected email users like gmail user.If yes then how can I do that? Currently I am using the Private Site plugin to lock my website.Please help me. Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi!

    You can try use filter ‘registration_errors‘. It should look something like this:

    function gmail_registration_errors($errors, $sanitized_user_login, $user_email)
    {
        if (!preg_match('/\@(gmail)\.com/', $user_email)) {
            $errors->add('gmail_error', __('<strong>ERROR</strong>: This is a not Gmail!'));
        }
        return $errors;
    }
    
    add_filter('registration_errors', 'gmail_registration_errors', 10, 3);

    insert this into your ‘functions.php’ or custom plugin.

    Thread Starter feriowala

    (@feriowala)

    Thank you very much. If I allow only gmail except all domains then what should be my code. I am sorry. I am not an expert of codding field. I can see that code will block gamil users.

    This code checks email that is entered by the user during registration. And if this email is NOT gmail.com it will show an error – ‘ERROR. This is a not Gmail!’. And registration will be rejected.

    Thread Starter feriowala

    (@feriowala)

    Yes I got it now. Thank you very much for the help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘New User Registration’ is closed to new replies.