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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dancablamCommented:
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!
dancablamCommented:
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shelzerChief Solution ArchitectAuthor Commented:
Thanks dancablam, when I get into the office tomorrow I'll try that first thing and let you know!
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

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 (form.name.value == "") {
                        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 (form.email.value == "") {
                        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 {
                        form.submit();

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?
dancablamCommented:
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.
dancablamCommented:
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!
dancablamCommented:
Glad to hear it! You're very welcome.

Dan
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.