Skip to content

Instantly share code, notes, and snippets.

@taricco
Created July 22, 2020 18:22
Show Gist options
  • Select an option

  • Save taricco/8ab7a450a34a67a887b4a2eb9da29acd to your computer and use it in GitHub Desktop.

Select an option

Save taricco/8ab7a450a34a67a887b4a2eb9da29acd to your computer and use it in GitHub Desktop.
/* 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 : '';
$blacklist = array( 'gmail.com', 'hotmail.com', 'outlook.com', 'aol.com', 'mail.com', 'yahoo.com', 'icloud.com' );
$parts = explode( '@', $value );
if( in_array( $parts[1], $blacklist ) ) {
add_filter( $filter_hook, function ( $msg ) use ( $field_label ) {
return __( 'You must use a business email address. Email addresses like @gmail.com and @outlook.com are not accepted.', '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