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

Reply
 
Thread Tools Display Modes
  #1  
Old 06-11-2008, 07:05 PM
DISLEX DISLEX is offline
 
Join Date: Apr 2006
Location: Odessa
Posts: 107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default I added a new user field but I'm having trouble

Fixed this issue, new issue below
Reply With Quote
  #2  
Old 06-11-2008, 07:13 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are you sure $vbulletin is availble at the hook?

You might need to use [minicode]$this->registry->userinfo['worksafemode'][/minicode]
Reply With Quote
  #3  
Old 06-11-2008, 07:14 PM
DISLEX DISLEX is offline
 
Join Date: Apr 2006
Location: Odessa
Posts: 107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

that might be it, I figured $vbulletin was available everywhere though

Is $vbulletin just $this->registry?
Reply With Quote
  #4  
Old 06-11-2008, 07:57 PM
MoT3rror MoT3rror is offline
 
Join Date: Mar 2007
Posts: 423
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

When vB uses a class they put $vbulletin as $this->registry so they don't have to global $vbulletin for each function.
Reply With Quote
  #5  
Old 06-11-2008, 08:18 PM
DISLEX DISLEX is offline
 
Join Date: Apr 2006
Location: Odessa
Posts: 107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

can this cause an issue with cached values?

cause I'm still coding and messing with SQL queries to change the setting (since I don't have a front end to do it yet). And I just forced the field to 0, but it's still catching it and transforming to a URL (meaning it thinks $this->registry...etc is 1, not 0)
Reply With Quote
  #6  
Old 06-11-2008, 08:35 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Not sure what you are on about cache... but $this->registry is just a reference to $vbulletin so they hold the same values.

Use var_dump() to check the values of variables if you need to.
Reply With Quote
  #7  
Old 06-11-2008, 08:38 PM
DISLEX DISLEX is offline
 
Join Date: Apr 2006
Location: Odessa
Posts: 107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah I figured out the issue, nevermind. But now I have a new one..

I'm trying to add an option for this userfield (a checkbox) on the edit->options page. However I'm running into some strange issues. I'm not completely familiar with it, but I'm essentially copying another plugin. They have a hook on profile_complete, and then they throw in $customfields in there. I've done this, and made a checkbox which shows up, but I have two issues:

1) It's not updating the field correctly. I'm sifting through the PHP and also the templates, and I'm really confused how vB handles custom checkboxes.

2) All the other checkboxes default to unchecked when I have this hook enabled. I have NO idea why, as I'm only changing custom variables and nothing global.

Any ideas?
Reply With Quote
  #8  
Old 06-11-2008, 08:59 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You have to extend the datamanager.

userfield refers to the Custom Profile Fields created in the AdminCP, you've manually altered the database so you need to alter the datamanager.

Find other modifications which do the same and see if you can learn from them. Check the articles section for information about Datamanagers there are articles there. There is also information in the vBulletin manual.

To be honest it would be easier to use the Custom Profile Fields in the AdminCP, then use fieldX in your code e.t.c
Reply With Quote
  #9  
Old 06-11-2008, 09:55 PM
DISLEX DISLEX is offline
 
Join Date: Apr 2006
Location: Odessa
Posts: 107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Opserty View Post
You have to extend the datamanager.

userfield refers to the Custom Profile Fields created in the AdminCP, you've manually altered the database so you need to alter the datamanager.

Find other modifications which do the same and see if you can learn from them. Check the articles section for information about Datamanagers there are articles there. There is also information in the vBulletin manual.

To be honest it would be easier to use the Custom Profile Fields in the AdminCP, then use fieldX in your code e.t.c
okay so you're talking about "User Profile Field" in AdminCP? Doesn't that only affect fields in "Edit Profile" and not "Edit Options"? Because I don't see any of the fields added by previous products under that menu option.

Also, this "data manager" you're referring to.. if I add a field to the User Profile Fields in Admin CP, is this altering the data manager like you're saying, or is that a different process?

--------------- Added [DATE]1213226533[/DATE] at [TIME]1213226533[/TIME] ---------------

This example code I'm looking, I just noticed it has another hook for profile_udateoptions, and it checks the variables and uses $userdata->set() to set the variables. I guess that's how it does it...?

--------------- Added [DATE]1213228973[/DATE] at [TIME]1213228973[/TIME] ---------------

Here is my code for profile_complete

Code:
if($_REQUEST['do'] == 'editoptions') {

  // MODE
  $profilefieldname = 'worksafemode';
  $mykey = 1;
  $myval = "Enable worksafe mode";

  $custom = "";
  $customfields['login'] .= "<fieldset class='fieldset'><legend>Worksafe Mode</legend>";
  $customfields['login'] .= '<table cellpadding="0" cellspacing="3" border="0" width="100%">
					<tr>
						<td>
							Check this box if you wish to enable worksafe mode, which enables worksafe-related features<br />
						</td>
					</tr>
					<tr>';
	
  $mychecked= $vbulletin->userinfo['worksafemode'] ? 'checked="checked"' : '';
  $custom .= '<td valign="top"><label for="cb_cpf_'.$profilefieldname.'_'.$mykey.'"><input type="checkbox" name="userfield['.$profilefieldname.'][]" value="'.$mykey.'" id="cb_cpf_'.$profilefieldname.'_'.$mykey.'" '.$mychecked.' />'.$myval.'</label></td>';
	
  $customfields['login'] .= $custom;

  $customfields['login'] .= "</tr></table></fieldset>";
}
profile_updateoptions

Code:
$wsmode = intval($vbulletin->GPC['userfield']['worksafemode']);

$userdata->validfields['worksafemode'] = array(TYPE_NOCLEAN, REQ_NO); 
$userdata->set('worksafemode' $wsmode, false);
I just tried to copy another plugin and this is the best I could come up with, hehe
Reply With Quote
  #10  
Old 06-12-2008, 05:49 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by DISLEX View Post
okay so you're talking about "User Profile Field" in AdminCP? Doesn't that only affect fields in "Edit Profile" and not "Edit Options"? Because I don't see any of the fields added by previous products under that menu option.
You can choose where to put them. Fields will not show in the Admin CP if they were not added via the Admin CP method.
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 01:52 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04614 seconds
  • Memory Usage 2,260KB
  • 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
  • (2)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete