Previous Thread
Next Thread
Print Thread
Rate Thread
#223538 09/02/2002 1:39 PM
Joined: May 2001
Posts: 32
Junior Member
Junior Member
Offline
Joined: May 2001
Posts: 32
How do I allow users to have spaces in their username?

I've looked through all the docs and admin stuff, but cannot find how to do it.
Is this something that will be allowed or added to a new release?

Thanks,

FC

Sponsored Links
Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
[6.1b1]

There's a config setting to allow special characters.

If special characters are not allowed, only "A-Z", "a-z", "0-9" and "_" are permitted.

If special characters are allowed, the only exclusions are " " (non-breaking space), "<", ">", leading space and trailing space.

If you want to allow spaces without allowing other special characters, you would need to change adduser.php. Look at the section of code starting with "// No special characters".

Last edited by Dave_L; 09/02/2002 2:46 PM.
Joined: May 2001
Posts: 32
Junior Member
Junior Member
Offline
Joined: May 2001
Posts: 32
Thanks, I should've seen that in the config area!

FC

Joined: Jun 2002
Posts: 375
Enthusiast
Enthusiast
Offline
Joined: Jun 2002
Posts: 375
Hmm, I'm guessin this is why none of the new users on my board have used a space in their name since I upgraded to UBBT from classic, LOL

I'll turn this on and cross my fingers to hope no smart*ss causes chaos and forces me to edit the code to allow spaces only, hehe

Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768


If you did want to add spaces for the no-special-characters case, you could do it like this:

adduser.php (6.1b1), change:

code:
// No special characters
if (!$config['specialc']) {
if (!preg_match("/^\w+$/",$Username)) {
$html -> not_right($ubbt_lang['BAD_UNAME'],$Cat);
}
}



to:

code:
// No special characters
if (!$config['specialc']) {
$username_pattern = '{
^\w # must start with word-character [A-Za-z0-9_]
[\w ]* # zero or more word-characters or spaces
\w$ # must end with word-character
}x'; # x-modifier removes whitespace and comments from pattern
if (!preg_match($username_pattern,$Username)) {
$html -> not_right($ubbt_lang['BAD_UNAME'],$Cat);
}
}




Sponsored Links
Joined: Jun 2002
Posts: 375
Enthusiast
Enthusiast
Offline
Joined: Jun 2002
Posts: 375
That code will allow new usernames to have a space or two, while still having the no special characters feature enabled?

Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
That is correct.

Joined: Jun 2002
Posts: 375
Enthusiast
Enthusiast
Offline
Joined: Jun 2002
Posts: 375
Thanks! Looks like it works great


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Nettomo
Nettomo
Germany, Bremen
Posts: 417
Joined: November 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240430)