The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Need some help with userfields
OK guys, please forgive me, but I am trying to port some antispam mods I had in my vB 3.0.xx site to the newest vB I plan to use in it and I have a problem. I am trying to alter register.php from vB 4.2.0 Patch Level 2.
Specifically, I need to grab the value of a userfield and compare it with the value I'll get from a table. It is a Single-selection menu field, I have it defined in the Profile fields, exactly as I had it in the old vB. It contains a list of countries and the registering member has to select one of them. I check $vbulletin->GPC['userfield']['field5'] (field5 is the name of the field) right before the register_addmember_process hook and I get a numeric value, which corresponds to the country the user has selected. What I want however, is the name of the country associated with that country value. In vB 3.0.xx I used $bbuserinfo['field5'] after I checked for errors and I got the country name. What am I supposed to check in vB 4.2?? Here is the part of the code I am looking at in register.php pf vB 4.2 Code:
else { $show['errors'] = false; // save the data $vbulletin->userinfo['userid'] = $userid = $userdata->save(); echo "HERE: "; echo ($vbulletin->userinfo['field5']); break; What is the variable I should use in : Code:
$country_name = some_variable_here??? I could use some help here guys, many thanks. |
#2
|
|||
|
|||
Try checking $vbulletin->GPC['userfield']['field5'].
|
#3
|
|||
|
|||
That returns the number too, not the country name. Tried that already.
Tnx |
#4
|
|||
|
|||
Oh, right, I see now where you said you tried exactly that.
OK, right below where you inserted you code is this code: Code:
if ($userid) { $userinfo = fetch_userinfo($userid,0,0,0,true); // Read Master Try checking $userinfo['field5'], somewhere after that code. The strange thing is that I can't see how $bbuserinfo would reflect the new value for field5 even in the vb3 code. |
#5
|
|||
|
|||
Thank you, yes, that worked. But that is below the area I want to have that information, ideally, I need to make that check before register_addmember_process hook, so that I can take whatever action I want to, inside that hook.
As for vB3, it's hard to tell you exactly where the conversion occured, in the standard file, my exisiting file is heavily, heavily patched, all those years, so it's not sure that everything I have in my file is in the vB version. But the conversion to $bbuserinfo occurs a little after the check for illegal user name. Look for this code in register.php, or part of this code: Code:
if (!empty($vboptions['illegalusernames'])) { $usernames = preg_split('/\s+/', $vboptions['illegalusernames'], -1, PREG_SPLIT_NO_EMPTY); foreach ($usernames AS $val) { if (strpos(strtolower($_POST['username']), strtolower($val)) !== false) { $username = &$val; eval('$errors[160] = "' . fetch_phrase('usernametaken', PHRASETYPEID_ERROR) . '";'); } } } --------------- Added [DATE]1356594046[/DATE] at [TIME]1356594046[/TIME] --------------- OK, it seems that the string I need is contained in the variable $customfields. It includes the wording "Country : Greece " and the trailing space, but these are easy to fix. OK, coming from vB3 (that was the last coding scheme I was familiar with), could you please tell me what these $userdata->set_userfields etc are? I mean it's not a function defined somewhere, so what are these things? Is there a document somewhere which explains the new coding scheme adopted by vB in vB 4.xx? Many thanks for your time my friend. |
#6
|
|||
|
|||
I'm glad you got it figured out. The registration code is pretty much the same as in vb3.8.X, so I guess you're coming from a version that's older than that.
Anyway, there's an article on the datamanagers here: www.vbulletin.org/forum/showthread.php?t=174090 which I just found so I haven't read it myself. Also if you're not familiar with the concept of classes and objects in php you might want to look at that: http://us2.php.net/manual/en/language.oop5.php BTW, set_userfields is a function that's defined in includes/class_dm_user.php, but you probably need to be familiar with php classes and objects to understand it. |
#7
|
|||
|
|||
Yes, I come from 3.0.xx. I used to be quite good at modifying vB back then, but I gave up on it, when they changed the coding scheme, I think it was in 3.5.
And yes, I am not familiar at all with classes and objects, so I can see some reading ahead. The good thing is that I managed to implement all my antispam measures in the current version, I just need to add some code for maintaining a table with log records, but that should be pretty straight forward. Thanks again for your help, I appreciate it. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|