CodeHQ

Registration white list | WordPress

Add this code in to your functions.php to create a domain whitelist for user registrations.

add_action('registration_errors', 'sizeable_restrict_domains', 10, 3);
function sizeable_restrict_domains( $errors, $login, $email ) {
	$whitelist = array(
        'domain.com', 
        'website.com'
    );
	if ( is_email($email) ) {
		$parts = explode('@', $email);
		$domain = $parts[count($parts)-1];
		$to = 'your@adminemail.com';
		$subject = 'Subject of email';
		$message = 'A user tried to register with the following email address: ' . $email;
		if ( !in_array(strtolower($domain), $whitelist) ) {
			$errors->add('email_domain', __('ERROR: You may only register with an approved email address.'));
		wp_mail( $to, $subject, $message );
		}
	}
	return $errors;
}