The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
I am trying to figure out what I need to do in order to user the User datamanager to update an existing user.
Most of the examples that I could dig up had to do with creating and saving a new user, but I'd like to update a user. Here's what I'm presently doing: Code:
$userdata =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY); $userdata->condition = ('userid = ' . $userid); $userdata->set('userid', $userid); $userdata->set('email', $email); $userdata->set('password', $password); $userdata->set('username', $username); $userdata->save(); I thought that setting $userdata->condition would signal that an update needs to be done. Looking at the code for the User datamanager it would seem that condition needs to be set to something anyway. Any ideas on what I'm missing here? Thanks! Rich --------------- Added [DATE]1212012154[/DATE] at [TIME]1212012154[/TIME] --------------- OK, I think I figured it out. I got something working for me anyway but so I thought I'd share. For some reason providing the username when an update is desired seems to have been causing the problem I described in my previous post. Here is my code now: Code:
$userid = $this->getUserId($username); $userdata =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY); if ($userid > 0) { $userdata->condition = ('userid = ' . $userid); $userdata->set('userid', $userid); } else { $userdata->set('username', $username); } $userdata->set('email', $email); $userdata->set('password', $password); $userdata->save(); Rich --------------- Added [DATE]1212012297[/DATE] at [TIME]1212012297[/TIME] --------------- One more thing. getUserId() is my own convenience function. It looks like this: Code:
// Userid for username. 0 if the user is not found. public function getUserId($username) { global $vbulletin; if (empty($username)) { return 0; // or whatever error you deem appropriate } $user = $vbulletin->db->query_first(" SELECT userid FROM " . TABLE_PREFIX . "user WHERE username = '" . addslashes(utf8_decode($username)) . "'"); return $user ? $user['userid'] : 0; } |
#2
|
|||
|
|||
![]()
Well I haven't had time to read through all your thread but here is how I would do it:
PHP Code:
|
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|