Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 827
  • Last Modified:

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!
0
shelzer
Asked:
shelzer
  • 5
  • 5
1 Solution
 
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!
0
 
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.
0
 
shelzerAuthor Commented:
Thanks dancablam, when I get into the office tomorrow I'll try that first thing and let you know!
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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

Dan
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now