Skip to content

Instantly share code, notes, and snippets.

@stevenhoney
Last active May 26, 2016 14:25
Show Gist options
  • Save stevenhoney/b42fb73dedffe503eb8a5c11b51ec2ed to your computer and use it in GitHub Desktop.
Save stevenhoney/b42fb73dedffe503eb8a5c11b51ec2ed to your computer and use it in GitHub Desktop.
Only allow users with an email address at a specific domain to register
function allow_single_email_domain( $user_login, $user_email, $errors ) {
if ( strpos( $user_email, '@youralloweddomain.com' ) != -1 ) {
return;
} else {
$errors->add( 'bad_email_domain', '<strong>ERROR</strong>: This email domain is not allowed.' );
}
}
add_action( 'register_post', 'allow_single_email_domain', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment