PDA

View Full Version : User DM


merk
06-12-2005, 12:23 PM
Im trying to modify a couple of userfields using the new user data manager.

code:


$userfields = array('field7' => $data1, 'field8' => $data2);

$userdata = datamanager_init('User', $vbulletin, ERRTYPE_STANDARD);
$userdata->set_existing($userinfo);
if($userdata->set_userfields($userfields))
{
$userdata->save();
} else {
echo "failed";
}


$userinfo is retrieved from fetch_userinfo();.

The script returns "failed". I have no idea why, and im having a bit of trouble following the class structures this late at night.

Any ideas? :)

Getting slightly closer, it appears the array needs to contain fieldx_set and _opt (set being set to 1, opt as far as i know set to 1 if the field is optional?)

Still didnt work though. /me keeps looking.

VBCoder
06-12-2005, 01:09 PM
The example showed using a =& datamanager_init , not just a plain =

merk
06-12-2005, 01:11 PM
Thanks for picking that up. Changed but $userdata->set_userfields is still returning false.

Its weird :\

Okay, found the problem. It appears that the array stuff earlier was partly to blame, and that non editable userfields are not updated by these functions.

Time to go report a bug :)

VBCoder
06-12-2005, 05:55 PM
merk, instead of if(set..) save(), try if (!$userdata->errors) save else print_r errors

(shorthand, but you get the idea)