You can do it easily by writing a code inside your theme’s functions.php file. here is the code:
function is_valid_email_domain($login, $email, $errors ){
$valid_email_domains = array("gmail.com","yahoo.com");// whitelist email domain lists
$valid = false;
foreach( $valid_email_domains as $d ){
$d_length = strlen( $d );
$current_email_domain = strtolower( substr( $email, -($d_length), $d_length));
if( $current_email_domain == strtolower($d) ){
$valid = true;
break;
}
}
// if invalid, return error message
if( $valid === false ){
$errors->add('domain_whitelist_error',__( '<strong>ERROR</strong>: you can only register using @gmail.com or @yahoo.com emails' ));
}
}
add_action('register_post', 'is_valid_email_domain',10,3 );
Source: https://www.eyeswift.com/allow-registration-from-certain-email-domain-wordpress/
Related Posts:
- how to disable user confirmation from administration?
- How can I find users that didn’t set a password?
- How to allow an user role to create a new user under a role which lower than his level only?
- How can I be certain that a user has verified their email after registration?
- WordPress auto login after registration not working
- Placeholder text for registration form
- Use the user_activation_key for other purposes
- How to check if the user registration is allowed/active?
- Custom registration form page/template
- Multi-steps WordPress registration : in 4 steps how to?
- Force users to complete their profile after they register? How to
- How to disable or protect against disposable email accounts?
- How to get user ID during registration and add it to a custom table
- Custom user profile, registration, login page with theme
- Limit content by user registration date
- What is the best way to avoid spammers registering to my blog?
- Advice on setting up a site with front end registration
- Restrict user registration to emails on a single domain
- Authenticating to WordPress, using my own authentication two-factor system
- How to add multiple existing users to a multisite site?
- WordPress members-only page with link visible only to members
- How do I show errors after validation with a custom form frontend?
- Send custom signup approval email to different Administrators selectively
- How can I verify users facebook ID that he provides during signup process
- After e-junkie payment, send a http post to register user automatically?
- Email confirmation in user registration form without a plugin
- How to pass external variables to the wp_new_user_notification_email filter?
- Plugin for limiting user registration based on ip with expiry period?
- How to bypass the username as a required field in registration and just use email address instead?
- Function to allow “Anyone can register”?
- Where are people registering on my website?
- How to disallow user to register with a specific word in the username?
- Can user login details be used for other applications?
- Change User Registration
- Users managed to register on website with no register button?
- Add value in user table when user is created
- Should I encrypt the response that triggers an Ajax action? Is nonce sufficient?
- Allow WooCommerce existing customers to checkout without being logged in [closed]
- Adding register & login at top right corner
- user_profile_update_errors hook not executing
- Restrict certain character combinations in username during registration
- How can I attach a user to another user with user meta
- All users/comments suspected as bot? [closed]
- WordPress registration without wp-login.php and wp-admin folder, is it possible?
- Register users without confirmation
- Include “registration.php” for custom registration form?
- Keep Logged in Users out of Admin Panel
- can registration be enabled programatically?
- How do I have now a duplicated user entry if this is not allowed (and I cannot replicate it)?
- How to set custom avatar for users?
- Filter for users on custom post type
- Registration area + reserved area
- Please suggest me some plugins in WordPress networking
- wordpress – user registration ( signup registration )
- How to add registration date and last login date to user list page
- Disable password limitations
- Front end register with custom fields
- Automatic Website user password generation
- How to integrate CAPTCHA on register page? [closed]
- How to hide some users to unlogged users [closed]
- call wp_insert_user in custom class doesnt work
- Register multiple users in one form
- Register through url
- Add ‘first name’, ‘last name’, ‘date of birth’ and ‘terms and conditions’ to register fields?
- How to show password fields on registration form w/o plugins
- Is there any way to not require email address or disable notification upon setting up a member?
- I want to remove the http:// that is added automaticly on the user profile adress
- Wikipedia – CMS
- define two login page url
- User with same Mail but a different additional info(like domain)
- remove (error:) from registration errors woocommerce
- Redirection after registration
- Easily adding multiple existing users to a multisite site
- Uploading/integrating custom user registration page
- Registration – website crashes, error 403
- Send a password to a user who has just registered for a member area
- The requested URL /wordpress/register/ was not found on this server
- Storing data to database and user registration
- Insert user register into my own user table instead of wp own user
- User Registration Moderate
- What is the best user experience for user to perform an action using email?
- Registration page as homepage
- Restrict certain roles registrations by domain
- Macros for WordPress, creating subdomains out of registrations for current domain
- Users Ultra: Hide asterisk for required registration fields?
- New User ID not working in custom function with user_register hook
- How to make user to logged into website & redirect to homepage after successful registration?
- Custom registration field to SQL database
- Multisite/Network What file to edit to change the “new blog” registration text
- Changing starting number of User ID
- How do spam users register while I’ve only enabled registration by Gmail via Janrain?
- first_name property missing inside register_user action hook
- What hooks, actions or filters i can use to customize wordpress registration page and form?
- Can email address be used as user name?
- Using a number for limiting registering or banning on multisite
- Website visible only to Registered users (non wp-admin)
- Plugin recommendation for directory site [closed]
- Limit username to specific characters (A-Z and 0-9)
- how can i inform other users about new user registration? [closed]
- MySQL query to list users who never signed in