Log in

View Full Version : Force first Letter to be Capitilized in userfields?


Wonksta
06-18-2011, 03:23 AM
Hi there,

Wondering if there is anyway to make it so that when a user inputs their Location the first letter is captilized?
E.g.

Location: Sydney instead of sydney or SYDNEY

Sarteck
06-18-2011, 07:41 AM
I'm not COMPLETELY sure, since I don't do vB3 anymore, and so I can't test.... But you could try this on the profile_updateprofile hook:


$my_location_field = 'field2'; /// NOTE -- Edit this if yours is different.
$location_data_entered = $vbulletin->GPC['userfield'][$my_location_field];
$new_location = ucwords($location_data_entered);
$vbulletin->GPC['userfield'][$my_location_field] = $new_location;
$userdata->set_userfields($vbulletin->GPC['userfield']);


That will also take into consideration spaces. For example, if I put "SOMEWHERE IN HELL" as my location, it would change it to "Somewhere In Hell". Of course, "In" should not be capitalized grammatically, heh.




I've not tested this (I don't have vB3, and though it should (in theory) also work on vB4, I'm just too lazy to try it out. XP

Wonksta
06-18-2011, 07:53 AM
Thanks mate I went to go try it but I cannot find 'profile_updateprofile' under Manage Plugs -> Plug Manager

/n00b

Sarteck
06-18-2011, 08:01 AM
Serious? I thought it would be there... It's on line 1,885 of the vB 3.8.7 profile.php page, as ($hook = vBulletinHook::fetch_hook('profile_updateprofile') ) ? eval($hook) : false;

:(

Sorry I couldn't have been more help.



(Just to be sure we're on the same page, you are choosing to "Add New Plugin" and choosing the profile_updateprofile from the drop-down menu, ya?)

Wonksta
06-18-2011, 08:09 AM
Ahh no we were not on the same page, thanks mate I will try this shortly I must head out now.

Thanks so much!

Sarteck
06-18-2011, 08:14 AM
Don't thank me until it actually works. XD

Also not that it will not change whatever you have in there already, if it does work--this will only work when someone enters new data.

(If it works at all.)

Wonksta
06-18-2011, 12:11 PM
Tried it now and it doesn't seem to work, bummer!

When the plugin is activated it wont let the user proceed to save the data because it says something else in another field is invalid even though fieldid is correct in the hook it messes with my other custom fields (drop down).

Ahh well!

Sarteck
06-18-2011, 12:28 PM
There's probably just something wrong with my coding. Hopefully someone else looking at this will be able to point it out, but I just don't know right now. If I'm bored later on, I'll give it a try on my own forum.

EDIT: Even though I'm vB4, it'll probably work the same. That section of the code seems to be the same for both 3.8.7 and 4.1.4.

Wonksta
06-18-2011, 12:29 PM
There's probably just something wrong with my coding. Hopefully someone else looking at this will be able to point it out, but I just don't know right now. If I'm bored later on, I'll give it a try on my own forum.
You're a good man Starteck, thanks again for your effort.