XF 2.0 How to disallow Spaces or Special Characters on usernames

I searched about it and found several answers but found no one that really fits what I was looking for,
I want to disallow spaces and special characters
But I do want to allow all the rest and the special character _
Example
Disallow:
john 123
john123!

Allow:
xenFORO123
Xenforo_123


How can I do this?
I have about 100 registered forum members some of whom have already registered with the characters I want to ban, what will happen to them?
In addition, how do I announce on the registration page which characters are not allowed.

Thanks a lot!
 
You will need to use regex for the user registration options - the exact string depends which characters you want to allow/prohibit.

Any existing members would have to be renamed by an administrator.
 
You will need to use regex for the user registration options - the exact string depends which characters you want to allow/prohibit.

Any existing members would have to be renamed by an administrator.

I find this code:
^[a-zA-Z0-9_]*$

But when i am trying to save its say :
Invalid regular expression

Why is it?
 
I find that it works if I surround the regular expression with the # character.

#^[a-zA-Z0-9\_\ ]+$#

I tried right now to sign up with user with space for example: user name10
And it completes the registration..
The space characters is still not considered prohibited, the rest of the characters yes


i put it inside User name match regular expression:

Did you use @AndyB code?
Code:
#^[a-zA-Z0-9\_\ ]+$#
I dont know, im doing the same as you
 
Back
Top Bottom