Here is a way to restrict registration to a specific email domain using following WordPress hook.
You can add more domains to restrict list by adding domain into $blockDomains. and also you can edit your custom error message(By changing $error_message)…
add_action('register_post', 'email_restrictions_on_registration', 10, 3); function email_restrictions_on_registration( $login, $email, $errors ) { // Add those specific email domain in '$blockDomains' array. $blockDomains = array('gmail.com', 'domain.com', 'domain-name.com'); //Add Your custom error message here. $error_message = "Only Email Addresses From Approved Domains Are Allowed!"; //Split email address with @ to get domain name. $email_data = explode('@', $email); $username = $email_data[0]; $domain = $email_data[1]; //Check if domain is in block Domain list. if(in_array($domain, $blockDomains)) { $errors->add( 'invalid_email', __("<strong>ERROR</strong>: $error_message"), array('form-field' => 'user_email') ); } }
Thank you for the good writeup. It in fact was a amusement account
it. Look advanced to more added agreeable from you!
However, how could we communicate?
You can contact me via Email. From Here:– https://paghdarakshay.wordpress.com/contact/
Yes! Finally something about the.
Pretty nice post. I just stumbled upon your blog and
wanted to say that I have truly enjoyed browsing your blog posts.
In any case I’ll be subscribing to your feed and I hope you write again soon!
Hi my loved one! I want to say that this article is awesome, great written and come with almost all important infos. I’d like to see extra posts like this .