Title: Custom validation error messages
Last modified: October 18, 2016

---

# Custom validation error messages

 *  [derekbaah](https://wordpress.org/support/users/derekbaah/)
 * (@derekbaah)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/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 &nbsp but it didn’t work.

Viewing 1 replies (of 1 total)

 *  [borisv](https://wordpress.org/support/users/borisv/)
 * (@borisv)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/custom-validation-error-messages/#post-8324989)
 * Line 1758 in wp-content/plugins/ultimate-member/languages/ultimatemember-en_US.
   po
 * I hope this helps,

Viewing 1 replies (of 1 total)

The topic ‘Custom validation error messages’ is closed to new replies.

 * ![](https://ps.w.org/ultimate-member/assets/icon-256x256.png?rev=3160947)
 * [Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin](https://wordpress.org/plugins/ultimate-member/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ultimate-member/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ultimate-member/)
 * [Active Topics](https://wordpress.org/support/plugin/ultimate-member/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ultimate-member/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ultimate-member/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [borisv](https://wordpress.org/support/users/borisv/)
 * Last activity: [9 years, 7 months ago](https://wordpress.org/support/topic/custom-validation-error-messages/#post-8324989)
 * Status: not resolved