Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 01-18-2008, 05:25 AM
chuanjer chuanjer is offline
 
Join Date: Nov 2004
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Hooks & User Profile field updation

I've written a plugin-script which is triggererd by usercp_complete .it will then update the Profile_status which is 'field6' in vb Userfield.
PHP Code:
$userdata =& datamanager_init('User'$vbulletinERRTYPE_ARRAY);
$userdata->set_existing($vbulletin->userinfo);  
$userdata->set('field6','Yes');
$userdata->pre_save();
if (
count($userdata->errors) > 0)
{
    
// Errors occurred. Do not proceed with the save.
    // You may want to loop through $dataman->errors and  
    // display the results the user.
}
else
{
    
// No errors occurred.
    // Proceed with the save (see the next step).
   
$userdata->save();

Keep getting this error:
Code:
Fatal error: Field field6 is not defined in $validfields in class vb_datamanager_user in /includes/class_dm.php on line 485
Whats wrong with the code?Thanks!
Reply With Quote
  #2  
Old 01-18-2008, 05:39 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, I think the error gives it away. Look in the class file, and look at the error.
Reply With Quote
  #3  
Old 01-18-2008, 06:01 AM
chuanjer chuanjer is offline
 
Join Date: Nov 2004
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't think that would help too much coz I cant change any stuff in the core vB PHP codes anyway.And the userfield of interest to me is not a standard vb core field like 'email' or 'referer' so its not set in the class anyway , it was defined by me in the Profile field section of the Admin CP and its named 'field6' by vB.basically what i wanna do is:

Edit the value of field6 in vb table 'usefield' , but I'd like to do so via vB & not by a mysql/php hack.
With this in mind, which Data Manager should I use? admin , user , post ....?

Thanks
Reply With Quote
  #4  
Old 01-18-2008, 06:48 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can add a "validfield" without changing vBulletin core files... Just add to the array.
Reply With Quote
  #5  
Old 02-15-2008, 02:13 PM
grant.hayman grant.hayman is offline
 
Join Date: Feb 2007
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi Dismounted,

I am trying to do something similar. ( add a value to a profile filed which will be posted (POST method) to register.php

Which array do I need to add to, whats the location of the array?

Thanks

Grant
Reply With Quote
  #6  
Old 02-15-2008, 02:57 PM
cheesegrits's Avatar
cheesegrits cheesegrits is offline
 
Join Date: May 2006
Posts: 500
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

chuanjet ... why would you be adding a custom profile field to the User dm in the first place? Custom fields aren't a part of the user dm, as that error message is telling you!

Easiest way would probably be to hang your plugin on the profile_start hook, check if $_POST['do'] is 'updateprofile', and if so poke your field6 value into the $_POST['userfield'] array, something like this:

PHP Code:
if ($_POST['do'] == 'updateprofile')
{
        
$_POST['userfield']['field6'] = "Yes";
        
$_POST['userfield']['field6_set'] = 1;

... and then just let the standard set_userfields() call in the 'updateprofile' processing handle it for you.

-- hugh
Reply With Quote
Reply

Thread Tools
Display Modes

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 10:49 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.04746 seconds
  • Memory Usage 2,209KB
  • Queries Executed 13 (?)
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
  • (1)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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_postinfo_query
  • fetch_postinfo
  • 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