View Full Version : How to force users to insert at least X characters into a given custom profile filed?
vithorius
12-04-2012, 10:44 AM
Does anybody knows how to force users to insert at least X characters into a given custom profile filed?
In the user's custom profile field 'Location' (city), I would like to force users to, at least, insert 3 (three) characters.
I've already searched through hacks here in vb.org, but found none... How to do it?
Thank you! :up:
You can create a plugin using hook location register_addmember_process and code like this:
if (!empty($vbulletin->GPC['userfield']['field2']) AND strlen($vbulletin->GPC['userfield']['field2']) < 3)
{
$userdata->error('phrasename');
}
Then you also need to create a phrase with the error message you want (set Phrase Type to "Error Message"), and replace 'phrasename' with the name of your phrase.
Lynne
12-04-2012, 08:47 PM
Can't you use the regex field and enter something like:
.{3,}
You can - I don't think I ever noticed that before. And it works, the only thing is that it only tells you that the value is "missing or invalid". But if you also edit the description to say that it has to be 3 or more chars, that works pretty well, with no plugins.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.