Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

limited characters for user name*

jeongweejeongwee Vanilla version 2.6 ✭✭
edited November 2013 in Vanilla 2.0 - 2.8

how to set limited characters for username ,

so guest cant select a username which is too long or too short.

also how to stop username include _ or . or - ?

vanilla 2.1b2

Best Answers

  • peregrineperegrine MVP
    edited November 2013 Answer ✓

    you could also override function by creating your own ValidateUsername...

    if (!function_exists('ValidateUsername')) {
       function ValidateUsername($Value, $Field = '') {
          $ValidateUsernameRegex = ValidateUsernameRegex();
    
          return ValidateRegex(
             $Value,
             "/^({$ValidateUsernameRegex})?$/siu"
          );
       }
    }
    
    
    
    
    you can also change the min and max length by 
    
    minimum 5 and max 10
    
    $Configuration['Garden']['User']['ValidationLength'] = array(5,10)
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    Answer ✓

    and the requisite change to your definition of the message generated by validation error.

    e.g.

    $Definition['UsernameError'] = "only lowercase letters allowed";

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Answers

  • hbfhbf wiki guy? MVP

    from a UI perspective you need to add a validation expression to the username field of the account creation form.

  • peregrineperegrine MVP
    edited November 2013

    @hbf said:
    from a UI perspective you need to add a validation expression to the username field of the account creation form.

    @jeongwee
    from a coding perspective, if you post questions without expressing your vanilla version, you will not only continue to give a bad example for future people who can't read the message at the top of the forum , but it will prevent people from trying to help you with the exact version you are using.

    Granted, there are some people who insist the discussion question MAY not or DOES not require your vanilla version, BUT it certainly can't hurt, and it can only help. It may be the same answer no matter what version of vanilla you are using, but it will rule out the possibility of multiple answers or the wrong answer based on assumption of vanilla version which may be incorrect.

    Sometimes consistency in ALWAYS providing vanilla version with question, can be an advantage.

    **Message at top:

    " When posting a question on the forum, please include the version number of Vanilla you are using."**

    k, k no apology necessary. proof will be when you post your future questions.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • jeongweejeongwee Vanilla version 2.6 ✭✭
    edited November 2013

    @peregrine said:
    from a coding perspective, if you post questions without expressing your vanilla version

    = = sry man...im dumb always forgot to tell version :O

    i wrote it into my name title ,so even if i still forgot it next time, ppl will see my version :)

    also if you can take a look at this http://vanillaforums.org/discussion/24707/symbloeditor-feedback#latest

    the reason i don wanna let username inlucde like "_" becoz it wont work with symboleditor, user have to change the link manually.

  • jeongweejeongwee Vanilla version 2.6 ✭✭

    @hbf said:
    from a UI perspective you need to add a validation expression to the username field of the account creation form.

    thx,may i know the steps, i donno how to do it.

    i wanna made it highest allowed 16Byte ,nolimited for lowest.

    and dont allowed include "_" and "." and "-" .

  • hbfhbf wiki guy? MVP

    sorry, only advice is free. there are lots of examples of form validation in existing plugins. otherwise see "Custom Plugin Development" in my signature.

  • peregrineperegrine MVP
    edited November 2013 Answer ✓

    you could also override function by creating your own ValidateUsername...

    if (!function_exists('ValidateUsername')) {
       function ValidateUsername($Value, $Field = '') {
          $ValidateUsernameRegex = ValidateUsernameRegex();
    
          return ValidateRegex(
             $Value,
             "/^({$ValidateUsernameRegex})?$/siu"
          );
       }
    }
    
    
    
    
    you can also change the min and max length by 
    
    minimum 5 and max 10
    
    $Configuration['Garden']['User']['ValidationLength'] = array(5,10)
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • jeongweejeongwee Vanilla version 2.6 ✭✭

    @peregrine thank you so much ! :)

  • peregrineperegrine MVP
    Answer ✓

    and the requisite change to your definition of the message generated by validation error.

    e.g.

    $Definition['UsernameError'] = "only lowercase letters allowed";

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.