• 60 characters seems a tad excessive and is causing my theme to explode in extreme cases. Users with extremely long usernames are causing hell in my forum which pulls the usernames straight from WordPress.

    Is there any way of reducing this number (without hacking the code preferably)? I’d like to set it to, say, 20 characters… a value, which to my mind seems rather reasonable.

    As I say, I’d rather not hack the hell out of the code ideally, mainly to avoid issues caused by future updates. However, if anyone does know where to find the code that would target this, please do chime in.

    Am I missing something obvious?

Viewing 3 replies - 1 through 3 (of 3 total)
  • There is a filter called ‘pre_user_login’ that you can use to alter the username after being submitted by the user.

    Inside this filter you can cut the username length to the number you desired. This doesn’t affect core WordPress code. You can write the filter inside functions.php of theme you are using.

    A similar post can be found in the forum titled “limiting username length” but it doesnt work for newer wordpress software.

    A slightly modified version can be found on a post “How to limit username length in wordpress?” It worked for me.

    there is no more registration.php in wp-include WP 3.1.3
    The other problem is that users actually register even with 3 letter username which causes problems too, as most db’s are configured to request at least 4 characters for a search.
    Better solution: $valid = strlen($username) > 5 && strlen($username) < 30;

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to set maximum username length’ is closed to new replies.