View Full Version : Check Titles - automatically correct
symptome
12-20-2010, 12:19 PM
I've got the problem, that many people use titles with plenty of !!!!!?????-Signs.
I always edit those titles to delete those signs.
Another typical faults is, that after a comma there is no space.
Isn't there a possibility that creation of a thread corrects those things in titles automatically?
Thanks!
BirdOPrey5
12-20-2010, 03:38 PM
I put together a quick plugin that will tell a user to fix a mistake (not fix it for them) if they enter more than one ! or ? or a combination of ?! in a row...
So:
This! Is! OK!
But
This is NOT OK!!!
Also it should stop commas with no space after them...
Good:
this is a good, comma usage!
Bad:
this will not,be allowed!
Go to your Admin CP -> Plugin Manager -> Add a New Plugin
Product: vBulletin
Hook: newthread_post_start
Title: Thread Title Punctuation Check
Code"
$checktitle = $vbulletin->GPC['subject'];
$regpat = "/[\w \(\)\[\]<>]+,[\w\(\)\[\]<>]/";
if ( strpos($checktitle, "!!") OR strpos($checktitle, "??") OR strpos($checktitle, "?!") OR strpos($checktitle, "!?") OR preg_match ($regpat, $checktitle) )
{
standard_error("Please fix the punctuation in the thread title. Excessive ! and ? are not allowed and commas must be properly spaced. <input type=\"button\" id=\"backbutton\" class=\"button\" value=\"Go Back\" title=\"\" tabindex=\"1\" onclick=\"{ history.back(1);}\">");
}
Set ACTIVE to YES
and SAVE.
symptome
12-20-2010, 05:37 PM
Simply brillant!
Thanks a lot!
I believe, I will add some more ;)
Like the 2 or 3 usual smileys ...
Or "..."
symptome
12-22-2010, 04:09 AM
Or would it be possible to write the above to be executed automatically without showing any error to the member?
BirdOPrey5
12-22-2010, 04:25 AM
Not that I can do... you might find someone else willing and able.
Something like this might work for you:
static $pattern = array('/!+/', '/\?+/', '/(!\?|\?!)[\?!]+/', '/,(\S)/');
static $replacement = array('!', '?', '\\1', ', \\1');
$vbulletin->GPC['subject'] = preg_replace($pattern, $replacement, $vbulletin->GPC['subject']);
(This allows ?! or !?, but you could change it to disallow that if you want).
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.