Created
July 22, 2020 18:23
-
-
Save taricco/addd9d0b9001987bb440338bdf55c9c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* https://wordpress.org/plugins/user-registration/ */ | |
function ur_validate_user_email( $single_form_field, $data, $filter_hook, $form_id ) { | |
$value = isset( $data->value ) ? $data->value : ''; | |
$whitelist = array( 'domain1.com', 'domain2.com', 'domain3.com' ); | |
$parts = explode( '@', $value ); | |
if( ! in_array( $parts[1], $whitelist ) ) { | |
add_filter( $filter_hook, function ( $msg ) use ( $field_label ) { | |
return __( 'You may only register with an approved email address.', 'user-registration' ); | |
}); | |
} | |
} | |
add_action( 'user_registration_validate_user_email','ur_validate_user_email', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment