Custom validation error messages
-
Is there a way to change the validation error texts in registration? When users enter a username with a space I want them to receive an error saying: “Username must not contain spaces.” I found the following snippet of code online but it only works when a username has “admin” in it.
add_action(‘um_submit_form_errors_hook_’,’um_custom_validate_username’, 999, 1);
function um_custom_validate_username( $args ) {
global $ultimatemember;if ( isset( $args[‘user_login’] ) && strstr( $args[‘user_login’], ‘admin’ ) ) {
$ultimatemember->form->add_error( ‘user_login’, ‘Your username must not contain the word admin.’ );
}
}I tried to change ‘admin’ to an empty space and   but it didn’t work.
The topic ‘Custom validation error messages’ is closed to new replies.