Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-26-2012, 07:53 PM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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;
From the two echos shown above, which I've added, I see the "HERE: " and then nothing.

What is the variable I should use in :

Code:
$country_name = some_variable_here???
To get the name of the selected country?

I could use some help here guys, many thanks.
Reply With Quote
  #2  
Old 12-26-2012, 08:07 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try checking $vbulletin->GPC['userfield']['field5'].
Reply With Quote
  #3  
Old 12-26-2012, 09:32 PM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That returns the number too, not the country name. Tried that already.

Tnx
Reply With Quote
  #4  
Old 12-26-2012, 11:53 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 12-27-2012, 05:54 AM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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) . '";');
			}
		}
	}
Darn, there should be a way to convert the numeric value to the string, by unserializing the profilefield data, but I do not know how to do it.

--------------- 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.
Reply With Quote
  #6  
Old 12-27-2012, 10:22 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 12-27-2012, 02:25 PM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:54 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04505 seconds
  • Memory Usage 2,222KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete