how to apply custom validation on user_login field
-
how i can apply custom validation on user_login field as user name must be unique.
whenever a user login with exiting user name the registration form giving error invalid user name
i want to change this error and want to show the user name already exits.hare is the code which i used
`add_action(‘um_custom_field_validation_username’,’um_custom_validate_username’, 10, 3);function um_custom_validate_username( $key, $array, $args ) {
if ( $key == ‘username’ && isset( $args[‘username’] )) {
if ( $args[‘username’] == ” ) {
UM()->form()->add_error( ‘username’, __( ‘username is to required’, ‘ultimate-member’ ) );
} elseif ( username_exists( $args[‘username’] ) ) {
UM()->form()->add_error( ‘username’, __( ‘The username entered is already registered’, ‘ultimate-member’ ) );
}
}
}
but whenever i register with same user name the form is not submitted and its hang
can anybody sort it out please.
- The topic ‘how to apply custom validation on user_login field’ is closed to new replies.