Author Topic: Username Condition  (Read 160 times)

AF

  • Active Member
  • **
  • Posts: 27
  • Karma: +1/-0
Username Condition
« on: January 31, 2012, 05:48:43 PM »
Hi there,

I am wanting to put in a condition for the username and limit the length of characters enter-able upon a user registering. At the moment people are in some cases using really long names which pushes into the next user space on some of the widgets etc.

Can someone, or Mav please let me know if this is Javascript or PHP controlled? and "which file/s" contains the username conditions where I can add or manipulate.

Many thanks.

maverick

  • Active Member
  • **
  • Posts: 1382
  • Karma: +93/-1
    • Etano Templates
Re: Username Condition
« Reply #1 on: January 31, 2012, 11:09:03 PM »
Look for the following code in processors/join.php and try changing the number 20 to something less.

      if (!preg_match('/^[a-zA-Z0-9_]+$/',$input['user']) || strlen($input['user'])<4 || strlen($input['user'])>20) {

4 is the least number of characters accepted and 20 is the max.
Etano Templates and Mods

http://www.maverickwebworks.com

AF

  • Active Member
  • **
  • Posts: 27
  • Karma: +1/-0
Re: Username Condition
« Reply #2 on: February 01, 2012, 01:35:35 AM »
That answer was far better than expected! saved me a lot of trouble.

Thanks heaps Mav

AF

  • Active Member
  • **
  • Posts: 27
  • Karma: +1/-0
Re: Username Condition
« Reply #3 on: February 01, 2012, 01:59:51 PM »
Ok it seems I spoke too soon. I have altered the file and set the value to 13 characters max, and tested it with a new account and also by checking the username with the "check" button.

The problem

1. If the username exceeds 13 characters - The check button accepts where it should not.
2. If I exceed the original default value of 20 char, instead of 13 then it returns the original error - (using the check button).

3. Upon sign up, it appears the max 13 character value is actually working, but if you exceed 13 characters there is no error returned, and instead it clears the form and you have to start again - the user will have no idea what is wrong.

The only option I know of is a skin regeneration which im not sure will fix it either, and skin regeneration keeps painfully 'timing out'. Is this time-out issue also fixable?

Any suggestions here?

Cheers
« Last Edit: February 01, 2012, 02:59:28 PM by AF »

maverick

  • Active Member
  • **
  • Posts: 1382
  • Karma: +93/-1
    • Etano Templates
Re: Username Condition
« Reply #4 on: February 01, 2012, 07:18:02 PM »
Ok, you'll also need to edit the js/general.js file so the numbers match your changes in the processors/join.php file.

In the js/general.js file locate the following around line 169 ...

function validate_user(str) {
   if (!is_alphanum(str) || !checkByteLength(str,4,20)) {
      return false;
   }
   return true;
}


So that the error message is correct, in the Admin panel go to "Skin Settings" and click "translate" and edit key string #63, which says the following ...

Please use only letters and digits for your username. 4-20 chars.



As far as the regeneration timing out, this has more to do with your server resources. I've personally never had any trouble with it, other than it can occasionally be a bit slow and take a few minutes. I can't recall any other users reporting having time out issues with the regeneration.
Etano Templates and Mods

http://www.maverickwebworks.com

AF

  • Active Member
  • **
  • Posts: 27
  • Karma: +1/-0
Re: Username Condition
« Reply #5 on: February 02, 2012, 03:59:06 PM »
Excellent, that has solved it and it's working fine now.

Many Thanks!