You’re looking in the wrong place.
When a user first attempts to register, their username and email is processed and sanitized inside the register_new_user()
function in wp-login.php
. This is where you want to do your filtering.
Before the user is created, WordPress will pass the sanitized user login, email address, and an array or errors through the ‘register_post’ action. If there are any errors after that, then the user is not added and they will see the errors in the UI.
So the following untested function might help:
function prevent_email_domain( $user_login, $user_email, $errors ) {
if ( strpos( $user_email, '@baddomain.com' ) != -1 ) {
$errors->add( 'bad_email_domain', '<strong>ERROR</strong>: This email domain is not allowed.' );
}
}
add_action( 'register_post', 'prevent_email_domain', 10, 3 );
Related Posts:
- Limit username to specific characters (A-Z and 0-9)
- Is it possible to remove username field from the registration page? If so, how?
- users table – user_name vs. nicename
- Google Apps login in wordpress
- How do I create a password reset link?
- How can I be certain that a user has verified their email after registration?
- Placeholder text for registration form
- Stop spam users from registering without disabling user registration?
- how to disable user confirmation from administration?
- How to prevent spam users registering even with registration disabled
- Mail isn’t sent after local site registration
- How to prevent certain usernames from being registered?
- Changing username after registration to get around the issue of having duplicate emails?
- Registration key
- User defined password at registration – registration email sends auto generated pass
- Creating a Closed WordPress Community Using Referral Codes
- Function like is_registration_page to check if current page is registration page
- How to allow more than one registered user to have the same email?
- Is there a maximum length to user passwords?
- Registering without e-mail adress!
- Batch users creation
- Checked checkbox?
- Set user password after creating user
- On user registration, if welcome mail sent, add post with new user as author
- How to allow wordpress to create username with symbols like +
- Does the user_register change in multisite?
- Registration options and approvals
- user activation email doesn’t work
- How to stop WordPress emailing a password
- Mobile User Registration
- Conditionally registering users
- WordPress Register Form
- On multisite, plugins are disabled prematurely when viewing the /wp-activate.php page file
- Adding register & login in WordPress website
- registration form not working
- How can I disable all client side new accounts without disabling new user accounts?
- Override default new user registration email with custom message (non sub-domain multi-site installation)
- Unique registration for new writers to sign up
- How to receive notifications when a new user registers
- Getting thousands of registration spam
- Regsitration form on External page
- Custom registration form with different registration process based on what’s selected
- Is that possible show user’s post after user login
- allow only lowercase user registrations
- How do I set user account inactive?
- Restrict partially matching usernames
- How to register a user to a group by an invitation code?
- Register form how to get Total Control of it
- Custom user registration
- Modifying the Default Registeration Page?
- Cannot login due to incorrect password right after registration?
- WordPress + bbPress registration user-unfriendly?
- Force display name to nickname wp
- wp_insert_user not returning anything
- register_settings callback function erases data
- Custom registration fields not validating
- wp_insert_user function not adding password field to database
- wp_register() displays logged in user as site admin
- Create a post with user_register doesn’t create title
- User activation in wordpress
- I need a custom Login Registeration in WordPress can somebody guide me?
- How to enable user registration for specific country and disable registration from all other countries?
- how to change the register process
- Is there a way to check the email of the user trying to register before he registers?
- Custom Registration Form Based on user location Woocommerce
- WordPress – Use user meta in ‘user_register’ after new registration
- Modify new user welcome email
- Not receiving any sign up mail, when user registers… Both admin & user
- Adding email list as registered users
- WordPress is sending an empty email after using wp_insert_user
- Placeholder text for ajax loaded conditional fields in the registration form
- Creating custom registration and login page in wordpress
- Create a unique username with validation on wordpress registration
- How can I fetch user registration age
- wp_insert_user if user exists
- Redirect to “Thank you” page after register new user on custom register form
- Updating User Meta using Theme My Login with Custom Fields
- WordPress doesn’t send a password (but only a username) after new user registration
- How to hide username on wordpress registration?
- What’s the Point of Spam Registrations?
- Add custom Date column to “All Users” admin panel in WP
- Can’t figure out how people are registering on my site
- Update a user field with a generated text
- WordPress not sending registration mail? (works on ‘lost password’)
- Custom user creation and auto login problem
- How to generate Registration no
- Prevent registration except through form
- wordpress custom registration
- Upon registration, redirect new user to Dashboard
- Problem with registration page
- Disallow google/other email plus and dot tricks when registering?
- How we get the success messages
- disabling emails received by admins every time a new user signs up (function not working)
- how to allow unregistred users to view normal posts [closed]
- wp-signup.php example template
- registration process with contact from 7? [closed]
- Limit access to a page
- A conditional button
- enqueue style google fonts in functions.php in array?
- Change default error message “This email address is already in use” when registering a new user in WordPress using Caldera Forms