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.
Options

How to limit usernames to just letters, numbers & underscores? (like Twitter)

Is there a way to set the username restrictions like Twitter's during registration?

I did some digging and I'm not sure how to edit this particular code so it's A-Z, a-z, 0-9, and _
$Configuration['Garden']['User']['ValidationRegex'] = '[a-z]';

And can I get feedback on these?

$Definition['UsernameError'] = "Username can only contain letters, numbers, and underscores, and must be between 3 and 15 characters long.";
(display rules)

$Configuration['Garden']['User']['ValidationLength'] = array(3,15)
(max username chararacters on twitter is 15)

Thanks! :)

Comments

  • Options
    hgtonighthgtonight ∞ · New Moderator
    edited January 2016

    The regex you are looking for is:

    [A-z_]
    

    The length restriction is:

    {3,15}
    

    So you put in your /conf/config.php file:

    $Configuration['Garden']['User']['ValidationRegex'] = '[A-z_]';
    $Configuration['Garden']['User']['ValidationLength'] = '{3,15}';
    

    I validated these options via http://www.phpliveregex.com/

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options
    hgtonighthgtonight ∞ · New Moderator

    @byakko said:
    Is there a way to set the username restrictions like Twitter's during registration?

    I did some digging and I'm not sure how to edit this particular code so it's A-Z, a-z, 0-9, and _

    I just realized I left out numbers in the regex. [A-z0-9_] will allow names to have numbers in them.

    Sorry about that.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

Sign In or Register to comment.