[REQUEST] Usernames w/ A-Z 0-9 Limit Addon

onetheycallgsk

New Member
Budi said:
Restrict usernames to alphanumeric and underscore - vBulletin.org Forum

I really need this post, and i think a lot of other people can benifit from this add on as well because there are some crazy people on vb forums who have just character names, and i have no idea what to call them by lol.

If anyone else can find a similar add-on, please post it!

Thanks Guys! =)

This can be done with vBulletin automatically. I'm not sure of the exact location in the AdminCP offhand, but I'm sure someone else could assist.
 

Budi

New Member
No, its not possible in the admin CP, its says so in the post aswell!

Can anyone else please help?!
 

dark_hunter

New Member
Will you all cut the crap and just give them the dam thing! Here you go mate.

Here are the instructions to do it.

1) Go to your Admin Control Panel, Phrases Manager and create a new phrase named "username_invalidchars" in the "Front-end error messages" section.

For the text use something like "Username has invalid characters. Only characters allowed are letters, numbers and underscore."



2.- Open /forums/register.php

Somewhere around line 187 you will find the following
PHP Code:
PHP:
$errors = array();


Add the following just below that
PHP Code:
PHP:
//-------------------------------------------------- 
    // check username does not contain UNWANTED characters 
    if (preg_match('/[^a-zA-Z0-9\_]+/', $_POST['username'])) 
    { 
        //eval(print_standard_error('error_username_semicolon')); 
        eval('$errors[11] = "' . fetch_phrase('username_invalidchars', PHRASETYPEID_ERROR) . '";'); 
    } 
//-------------------------------------------------



That's it, enjoy it.
 

onetheycallgsk

New Member
If I'm not mistaken, couldn't this also be accomplished through the AdminCP using the following URL:

admincp/options.php?do=options&dogroup=register

and using the Username Regular Expression form to restrict characters in usernames?


AdminCP said:
You may require the username to match a PCRE-type regular expression.

(Do not start or end the expression with an escape character)

Examples:

^[A-Z]+$ - Characters from A-Z only
^[A-Z ]+$ - Characters from A-Z including space
^[A-Z0-9 ]+$ - Alphanumeric characters including space
^((?!&#\d+;)[\x20-\x7E])+$ - ASCII characters from 32-127

See PHP.net for more information on regular expressions.
 

Budi

New Member
Thanks to both of you, but i think ill stick with the first one. The second option seems a little easier, but is there a-z and #s with no spaces? b/c i don't see that option, but anyways, thanks guys!
 

Budi

New Member
Actually the second method is easier!

You didn't list this onetheycallgsk but:

For Alphanumeric with no spaces, enter:

Code:
^[A-Z0-9]+$

Lol, i just took out the space inb/w the 9 and ]

Now, how can i allow underscores? _
 

onetheycallgsk

New Member
I'm not sure since I don't use the feature on my forums, but the link I provided for PHP.net (I think?) may be able to assist you.
 

Budi

New Member
Ok i did some experimenting and cam up with a standard username restrictions:
Code:
^[A-Z0-9_]+$
This allows A-Z 0-9 and '_'

One more thing, how to restrict the use of only 1 underscore? or else someone could make a name like: Joe_______Johns
 
Top