Joomla administration - Changing the username length

I've searched all of the Joomla forums and I know that this is possible, but I can't find the solution.

I've set up the Joomla CMS for an internal company intranet, and everything is running great. I am in the process of adding users, and one company requirement is that the usernames be 2 characters. I am getting an error stating that "the login contains inavalid characters or is too short". (It doesn't contain invalid characters)

I'm completely new to PHP, but I've been browsing through the files and I cannot find where to change this. (There is no setting in the administration - it needs to be coded)

If anyone knows how to "hack" this, I would appreciate as much detail as possible.

Thank you!
shelzerChief Solution ArchitectAsked:
Who is Participating?
Even better, search for the exact error message you're getting to make it easier, and look in the php file that's giving you the error message. So look at your browser when you receive "the login contains inavalid characters or is too short" message and then navigate to that .php file. Open it and search for "the login contains inavalid characters or is too short" (or whatever the error message is exactly). and then look before it - you should see a strlen or something there. Feel free to post the code that you find on here and I can help you modify it.
I would search through all of the php files for: strlen

Somewhere there is probably a statement that says something similar to:
if(strlen($var) < $x) echo "too short!";

change the value of $x to 1, for instance, and you should be cured!
shelzerChief Solution ArchitectAuthor Commented:
Thanks dancablam, when I get into the office tomorrow I'll try that first thing and let you know!
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

shelzerChief Solution ArchitectAuthor Commented:
Do you have any idea where I would find this? I've searched through com_users, com_registration, etc... "strlen" is not found anywhere, and either is the error message. I've even searched the config files. Thanks so much for your help!
shelzerChief Solution ArchitectAuthor Commented:
Well I did find this in admin.users.html.php:                  

                        // do field validation
                  if ( == "") {
                        alert( "<?php echo _REGWARN_NAME;?>" );
                  } else if (form.username.value == "") {
                        alert( "<?php echo _REGWARN_UNAME;?>" );
                  } else if (r.exec(form.username.value) || form.username.value.length < 2) {
                        alert( "<?php printf( _VALID_AZ09, _PROMPT_UNAME, 4 );?>" );
                  } else if ( == "") {
                        alert( "<?php echo _REGWARN_MAIL;?>" );
                  } else if ((form.password.value != "") && (form.password.value != form.verifyPass.value)){
                        alert( "<?php echo _REGWARN_VPASS2;?>" );
                  } else if (r.exec(form.password.value)) {
                        alert( "<?php printf( _VALID_AZ09, _REGISTER_PASS, 4 );?>" );
                  } else {

I changed form.username.value.length to "<1)" and now I'm getting a different error, so apparently this setting is in more than one place. Any thoughts?
Gotchya - it appears that they're using JavaScript for the form validation. You did the right thing by changing <2 to <1, but they might have some other logic in the actual PHP. What is the other error you receive after making that change?
shelzerChief Solution ArchitectAuthor Commented:
I also found this string in joomla.php and commented it out completely:

            /*if (eregi( "[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", $this->username) || strlen( $this->username ) < 1) {
                  $this->_error = sprintf( _VALID_AZ09, _PROMPT_UNAME, 2 );
                  return false;*/

Same error:

"Please enter a valid Username:. No spaces, more than 2 characters and contain 0-9, a-z,A-Z"

So it's seeing that the username can only be 2 characters now, so we are getting there.
Hmm, that's strange - I downloaded joomla and looked through it - that is the only file that triggers that error message. I'd make sure that after commenting it was saved and that the javascript is also still changed. Other than that, I'm not sure how that error message could be generated.
shelzerChief Solution ArchitectAuthor Commented:
It works! For some reason I have 2 instances of joomla.php... I edited both of them (just changed the number) and it works now. Thank you!
Glad to hear it! You're very welcome.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.