Tag Archives: Auto Registration

Vbulletin Auto registration script

1)Create a file with desired name (let it be vb_register.php) with the following code

function qpc_post($varname){
return trim(stripslashes((get_magic_quotes_gpc()) ? $_POST[$varname] : addslashes($_POST[$varname])));
}

define(‘THIS_SCRIPT’, ‘vb_register.php’);

require_once(‘./global.php’);
require_once(‘./includes/class_dm.php’);
require_once(‘./includes/class_dm_user.php’);

$userdm = new vB_DataManager_User($vbulletin, ERRTYPE_ARRAY);

$userdm->set(‘username’, qpc_post(‘username’));
$userdm->set(’email’, qpc_post(’email’));
$userdm->set(‘password’, qpc_post(‘password’));
$userdm->set(‘usergroupid’,qpc_post(‘usergroupid’));
$userdm->set(‘ipaddress’, qpc_post(‘ipaddress’));
$userdm->set(‘referrerid’, qpc_post(‘referrername’));
$userdm->set(‘timezoneoffset’, qpc_post(‘timezoneoffset’));
$userdm->set_bitfield(‘options’, ‘adminemail’, intval(qpc_post(‘adminemail’)));
$userdm->set_bitfield(‘options’, ‘showemail’, intval(qpc_post(‘showemail’)));
$firstname=qpc_post(‘firstname’);
$lastname=qpc_post(‘lastname’);
$dst_setting = intval(qpc_post(‘dst’));
switch ($dst_setting)
{
case 0:
case 1:
$userdm->set_bitfield(‘options’, ‘dstonoff’, $dst_setting);
break;
case 2:
$userdm->set_bitfield(‘options’, ‘dstauto’, 1);
break;
}

#If there are errors (eMail not set, eMail banned, Username taken, etc.) you can check for errors using
if (count($userdm->errors)) {
for($i=0; $ierrors); $i++) {
print “ERROR{$i}:{$userdm->errors[$i]}n”;
}
} else {
# If everything is OK
$newuserid = $userdm->save();
echo “1”;
}

2)Upload the file to the server where the vBulletin is installed

3)Paste the below given code , immediately after the code that register a user in the main site .
$url=”http://www.example.com/forum/vb_register.php”;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, “username=$mem_username&email=$mem_email&password=$mem_password&usergroupid=2”);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
curl_close ($ch);

// http://www.example.com/forum/ is the location where vbulletin is installed