UBB.Dev
Posted By: flyingcrow spaces in usernames - 09/02/2002 8:39 PM
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
Posted By: Dave_L_dup1 Re: spaces in usernames - 09/02/2002 9:29 PM
[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".
Posted By: flyingcrow Re: spaces in usernames - 09/04/2002 8:02 AM
Thanks, I should've seen that in the config area!

FC
Posted By: Aglavalin Re: spaces in usernames - 09/04/2002 9:30 AM
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
Posted By: Dave_L_dup1 Re: spaces in usernames - 09/04/2002 3:24 PM


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);
}
}



Posted By: Aglavalin Re: spaces in usernames - 09/04/2002 11:13 PM
That code will allow new usernames to have a space or two, while still having the no special characters feature enabled?
Posted By: JustDave Re: spaces in usernames - 09/04/2002 11:16 PM
That is correct.
Posted By: Aglavalin Re: spaces in usernames - 09/04/2002 11:52 PM
Thanks! Looks like it works great
© UBB.Developers