Custom username validation not working
-
Hi,
I am using Ultimate Member version 2.6.11 on WordPress version 6.3.1. I am having trouble with my custom username validation code.
I am trying to validate the username field to make sure that it contains the string “1234”. I am using the following code:
add_action( 'um_submit_form_errors_hook', function( $args ) { if ( isset( $args['mode'] ) && 'register' === $args['mode'] ) { if ( !str_contains( $args['user_login'], '1234' ) ) { UM()->form()->add_error( 'user_login', __( 'Username must contain the string "1234".', 'ultimate-member' ) ); } } }, 8, 1 );
However, this code is not working. I am still able to register users with usernames that do not contain the required string. Can you please help me?
Thank you
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Custom username validation not working’ is closed to new replies.