Skip to content

Instantly share code, notes, and snippets.

@cryptexvinci
Created August 3, 2022 05:28
Show Gist options
  • Save cryptexvinci/cc30c6ae3409c481f5ce59d0b531fdc7 to your computer and use it in GitHub Desktop.
Save cryptexvinci/cc30c6ae3409c481f5ce59d0b531fdc7 to your computer and use it in GitHub Desktop.
Ultimate Member Registration - List "disallowed" domain extensions such as .ru and .in
<?php
add_action( 'um_submit_form_errors_hook__registration', 'um_custom_validate_username', 99 );
function um_custom_validate_username( $args ) {
static $domain = '.in, .ru';
if ( isset( $args['user_email'] ) ) {
if ( str_ends_with( $args['user_email'], '.in' ) || str_ends_with( $args['user_email'], '.ru' )) {
$message = sprintf( __( 'Cant use email domain %1$s for registration', 'ultimate-member' ), $domain );
UM()->form()->add_error( 'user_email', $message );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment