PDA

View Full Version : Prevent shouting in usernames.


Jolten
03-16-2005, 10:00 PM
What's this do?
If you're like me you hate users who register with names like USERNAME. What this mini-hack does is transform all uppercase usernames upon registration to lowercase with an uppercase first letter. This "borrows" a function from the posting functions, therefore if you've got "prevent shouting" applied for posts it will also effect usernames. Preventing shouting in usernames. It will still allow all lowercase names or mixed case names to register properly.

Time to intall: less than 5 minutes
Queries: 0
Files to edit:1
Templates to edit: 0

Open register.php

find:

// convert any whitespace to a single space to prevent users entering 'user one' to look like 'user one'
$_POST['username'] = trim(preg_replace('#\s+#si', ' ', $_POST['username']));



BELOW it add:

// prevent username shouting
function fetch_no_shouting_text($text)
{
// stops $text being all UPPER CASE
global $vboptions;
return iif($vboptions['stopshouting'] AND $text == strtoupper($text), ucwords(vbstrtolower($text)), $text);
}
$_POST['username'] = fetch_no_shouting_text($_POST['username']);


Save

upload

Your done!

This does not effect users already registered. It only prevents new registrations form shouting usernames.

There shouldn't be any support needed, but if there is, I'll handle it exclusively in this thread.


Version history
-------------------------------

v1.00 //initial release

v1.1 // updated to only prevent all uppercase usernames.

sabret00the
03-17-2005, 06:02 PM
you don't need the ucwords function and the strtolower, ucwords should if i read correctly convert all but the first letter to lower, or make all but the first letter to lower.

also by installing this hack you make sure that every username starts with an Upper and the rest are Lower, that could be annoying for a user like me who has his whole username lower by choice.

what would be nice is if you could check if it was shouting then only convert the shouted usernames to lowercase.

oh well bar that, nice addition, it's always nice to see something new being released. :)

Jolten
03-17-2005, 06:13 PM
ucwords will not convert characters internally to lowercase so usernames would still appear as UsERnaMe. Therefor the strtolower is necessary.

I realize some users prefer an all lowercase username. That may be an addition to this hack. But right now, this prevents most odd case usernames.

Jolten
03-17-2005, 07:03 PM
Okay.. I've updated the hack. It will now only prevent all uppercase names if you have your vbOptions set to prevent shouting.

sabret00the
03-18-2005, 07:57 AM
ucwords will not convert characters internally to lowercase so usernames would still appear as UsERnaMe. Therefor the strtolower is necessary.

I realize some users prefer an all lowercase username. That may be an addition to this hack. But right now, this prevents most odd case usernames.
my bad :(

good luck with it :)

Jolten
03-18-2005, 11:43 PM
gee. I guess no one wanted this at all :)

ResaleBroker
03-20-2005, 05:25 PM
That seemed to work great. Thank You!

007
04-22-2005, 04:07 AM
Installed! Thanks!

PIKenPIK
04-22-2005, 05:10 PM
Thanks ... gettin' a Hangover from those members :tired:

** Clicks Install **

Jenta
05-12-2005, 11:38 PM
you know what i would like
make them go back and edit it...return an error

make them mend their riduculous names themselves
jeez i cant stand people that shout with their names
i even have it in big bold letters...do not use all caps!
but they still do

heh, found it
https://vborg.vbsupport.ru/showthread.php?p=495219#495219 :up:

007
09-10-2005, 08:25 PM
Anybody else want this for 3.5 as a plugin?? I sure would...

tanyeri24
06-10-2006, 02:53 PM
There a option to give cumstom characters lik if it's İ then convert to i etc..

tanyeri24
06-10-2006, 02:55 PM
is this hack also available for 3.5.x ?

Chadi
10-12-2006, 03:27 PM
Does this work on 3.6.2?

karabaja3
03-31-2008, 09:43 AM
this is not supported for 3.6.8.?

Jolten
03-31-2008, 11:43 AM
Sorry. I am no longer developing anything for vBulletin. I have changed the settings to allow someone reuse this code in some other modification if they wish. And if anyone wants to update it for more modern versions of vBulletin, they have my permission.