Wordpress Username Length

Hello Everyone!

I am trying to implement something on my wordpress blog, but I am not having any luck. I would like to implement a max and min username length. From what I gather, wordpress has a built in limit of 60 characters. I would like to lower this limit to 18. In extreme cases, my theme breaks over 18 characters. Also, if possible, I would like to make the minimum length 5 characters. Any idea how I would accomplish this?

Thank you in advance!

You are reading it correctly. Looks like you have to hack the new user page to check the character length. you can either do it via AJAX or php. Ajax would mean it would check right there. PHP would check after submit

Thats for the quick reply. I found that as well, but I do not have a clue how to use it. Any idea?

One reason why I did not pursue this method was because it appears to have one negative aspect. If I am reading it correctly, it appears to reduce the username after the user submits their name. This may just be me, but that does not seem as optimal as it telling the user that their name is too long.

For example, if I set the limit to 15, it sounds like this will reduce any name over 15 to 15 automatically. If a user were to enter “Mynameisbillybobjoe” wordpress would automatically crop it to “Mynameisbillybo”, which could have a completely different meaning to the user.

Thanks in advance

No no, you would use AJAX to count the chars in the text field. if(value<5){ a too short message is displayed}. if(value>18){ too long}. if you use twitter, it counts down your characters.

I am unsure of the answer to your question. Could you maybe just wrap the username in a span, then play with the CSS/PHP?


if(username >18){
 $username = // use a string function to chop at say 14 char
 echo $username.'...';
}

This is in reply to #6

With a little bit of digging, it appears that someone has this fix for a max length of a post title

function maxWord($title){  

2     global $post;  

3     $title = $post->post_title;  

4     if (str_word_count($title) >= 8 ) //set the maximum number of words  

5         wp_die( __('Error: Your post title has exceeded the maximum word limit.') );  

6 }  

7 add_action('publish_post', 'maxWord'); 

Would it be possible to make it function for the username? A php based fix would be fine, but it would be even better if it could be ajax based. Does this look like it is in the right direction?

Thanks in advance

Hm yes you are right about that, till you dont find a suitable answer you can just simply put a message next to the box where the users are entering their desired usernames that it should be up to 15 characters.

Yes, that is roughly what #8 was getting at

Thank you both for the reply.

I will see what I can find in terms of googling Ajax wordpress username length. In my two years or so with wordpress, it has always seemed like someone else has had the same problem as I have or they have had something very similar. For that reason, there always seems to be a workaround or fix available. I find it strange that I have not uncovered some fix or workaround. Does that imply very few people have this issue?

Thanks again

This is about the max. lenght: http://wordpress.org/support/topic/how-to-set-maximum-username-length