Quote:
Originally Posted by php-resource.de
I guess you are using the global $db within your CMS.
Try the following workaround:
PHP Code:
$registry = $vbulletin;
unset($vbulletin);
$vbDb = $registry->db;
//declare as global vbulletin's registry and db objects
global $vbulletin,$db;
$vbulletin = $registry;
//backup the original $db object (new!!)
$backupdb = $db;
$db = $vbDb;
/*
* Your code here
*/
// Restore your $db object (new!!)
$db = $backupdb;
|
I just wanted to say that I was implementing this article with Wordpress and kept getting errors about functions_databuild.php on line 1685. So I added "global $vbulletin" and started having the issue of class_dm.php on line 177 about Registry Object. The above code worked for me.
So here's my function (A combination of those in this article for wordpress)
Code:
// Function for vB registration //
function register_in_vb($username, $password, $email){
define('VB_AREA', 'External');
define('SKIP_SESSIONCREATE', 0);
define('SKIP_USERINFO', 1);
define('CWD', 'ABSOLUTE_VB_PATH' );
require_once(CWD . '/includes/init.php');
$registry = $vbulletin;
unset($vbulletin);
$vbDb = $registry->db;
//declare as global vbulletin's registry and db objects
global $vbulletin,$db;
$vbulletin = $registry;
//backup the original $db object (new!!)
$backupdb = $db;
$db = $vbDb;
$newuser =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY);
$newuser->set('username', $username);
$newuser->set('email', $email);
$newuser->set('password', $password);
$newuser->set('usergroupid', 3);
if(empty($newuser->errors)){
$db = $backupdb;
return $newuser->save();
}else{
$db = $backupdb;
return $newuser->errors;
}
}
and I called it on wp-login.php in the register_new_user function. I added it right after the User Password Generation so I could pass it to vB.
Code:
// Add the users to vBulletin
$newuserid = register_in_vb($user_login, $user_pass, $user_email);
That should help some people if you come across this :P