vb4 Illegal User Names & Username Regular Expression

Author:
phil
Created:
Wednesday, April 07th, 2010
Last Updated:
Wednesday, April 07th, 2010

Disclaimer: Accessing the information on this page means you agree to the Sites Terms of Service


My purpose in this is to give a decent example of how to use vBulletin's registration options: "Illegal User Names" along with its "Username Regular Expression" and allow comments to help build a working page dedicated to setting up a robust registration username process.

---

Recently setting up a vBulletin Forum for some folks, I ran across the registration settings of "Illegal User Names" where the admin can explicitly block a list of pre-defined usernames to prevent new users from registering themselves as: administrator, moderator etc. Out of the box, vBulletin will allow ALL characters whether ASCII or alphanumeric. Reading a few forums, others have had problems with the allowed use of certain ASCII characters and certain misleading words or the use of a "white space" in a username (Ex. john smith) which leads to people forgetting they put a space in their username and send e-mails to the admins to request a password change because they can't remember their password (they actually remember their passwords, not their username...) Anywho, lots of ways to create headaches...

What's nice about the Illegal User Names input, is the ability to block a user from registering any username based off of a shortened version. For example, if you add "mod" as an illegal username, it will also block "moderator" "sysmod" or anything that might mislead forum users of someone being a moderator.

Now, me personally, I decided to block some of the foul language words such as "fuck", "bitch", "shit", "asshole" etc. and I decided that I wanted the use of alphanumeric characters, along with an underscore: _ period: . and hyphen: -

While the extra characters are nice, if the "Illegal User Names" section isn't setup properly, it can create a scenario where a user can register with a username such as: "______" or "..." or "-----".

I won't go into a whole lot of explanation detail on how things work or why, but I will at least show what I did to make things work.

1) Login to the vBulletin Admin cPanel
2) Options -> User Registration Options
3) Look for the heading: Illegal User Names
4) Add any words you want to block.
5) Look for "Username Regular Expression" (right under Illegal User Names)
6) Add the following: ^[A-Z0-9_\.\-]+$

Now that you have that setup, go back to the Illegal User Names and add the following:

.. __ --

which will prevent someone from registering "------" etc.

At this point, this is merely a collection of thoughts... I would love to add to it provided [you] send in info on usernames worth blocking and regular expressions that tickle your fancy. If you do leave a comment with a regular expression, be sure to explain what all it blocks for those of us who don't fully understand how regular expressions work.

List of Illegal User Names

bitch fuck asshole shit admin mod sysop

List of Regular Expressions

Borrowed from: WebCheatSheet.com
Here is a great starting point of regular expressions to use

Regular ExpressionWill match...
fooThe string "foo"
^foo"foo" at the start of a string
foo$"foo" at the end of a string
^foo$"foo" when it is alone on a string
[abc]a, b, or c
[a-z]Any lowercase letter
[^A-Z]Any character that is not a uppercase letter
(gif|jpg)Matches either "gif" or "jpeg"
[a-z]+One or more lowercase letters
[0-9\.\-]?ny number, dot, or minus sign
^[a-zA-Z0-9_]{1,}$Any word of at least one letter, number or _
([wx])([yz])wy, wz, xy, or xz
[^A-Za-z0-9]Any symbol (not a number or a letter)
([A-Z]{3}|[0-9]{4})Matches three letters or four numbers

Post Comment

Comments

Very useful!!

Just wondering why you decided not to use lowercase letters?

Hum, to be honest, I don't know... lol

For some reason, It will accept upper and lower with the posted configuration... I guess if it is forcing uppercase for you, then put in :^[a-zA-Z0-9_\.\-]+$ instead.