How to Set a Maximum Length for Usernames?

In UsersWP, you can easily set a max length attribute for usernames, thereby ensuring that usernames cannot be longer than the specified length value. 

Code Snippet to Set Max Length Attribute for Usernames

You can use the following code snippet to set the max length attribute for usernames upon registration.  

We recommend using the Code Snippets plugin.

add_action( 'uwp_template_after', 'uwp_template_after_custom_callback' );
function uwp_template_after_custom_callback($type){
	if( 'register' == $type  ){
				jQuery(".uwp-registration-form #username").prop('maxlength','6');

The above code will limit the maximum length of usernames to six characters. You can replace the numeric value to any value of your choice. 

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.