How to limit the number of characters displayed on User's Name on menu

On menu in desktop version the name of the user is displayed on the right on the end of the row, there is some code snippet to limit the number of the characters?

captura name

There’s no easy way to do this to a specific number with CSS, but it can be done during the registration (if you enabled a separate Username field). Are there some issues with overflowing text in the header section or do you mean setting the character limit for all usernames by default?

I mean to set a limit for all usernames, because if the username is more than 12 characters they will broke my header design on desktop version

Please try this PHP snippet to restrict the username to 12 characters

add_filter(
	'hivepress/v1/forms/user_register',
	function ($form){
		if(isset($form['fields']['username'])){
			$form['fields']['username']['max_length'] = 12;
		}
		
		return $form;
	},
	1000
);
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.