vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Hooks & User Profile field updation (https://vborg.vbsupport.ru/showthread.php?t=168084)

chuanjer 01-18-2008 05:25 AM

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!

Dismounted 01-18-2008 05:39 AM

Well, I think the error gives it away. Look in the class file, and look at the error.

chuanjer 01-18-2008 06:01 AM

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 ....? :confused:

Thanks

Dismounted 01-18-2008 06:48 AM

You can add a "validfield" without changing vBulletin core files... Just add to the array.

grant.hayman 02-15-2008 02:13 PM

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

cheesegrits 02-15-2008 02:57 PM

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


All times are GMT. The time now is 08:08 AM.

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.00996 seconds
  • Memory Usage 1,726KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete