SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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!

  2. #2
    SitePoint Zealot theentry's Avatar
    Join Date
    Sep 2010
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  4. #4
    SitePoint Zealot theentry's Avatar
    Join Date
    Sep 2010
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    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
    Ryan B | My Blog | Twitter

  6. #6
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  7. #7
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With a little bit of digging, it appears that someone has this fix for a max length of a post title

    PHP Code:
    function maxWord($title){  

    2     global $post;  

    3     $title $post->post_title;  

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

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

    }  

    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

  8. #8
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    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?
    PHP Code:
    if(username >18){
     
    $username // use a string function to chop at say 14 char
     
    echo $username.'...';

    This is in reply to #6
    Ryan B | My Blog | Twitter

  9. #9
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ttpyro View Post
    With a little bit of digging, it appears that someone has this fix for a max length of a post title

    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
    Yes, that is roughly what #8 was getting at
    Ryan B | My Blog | Twitter


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •