As this is a common request for integration purposes, I thought I should write up another HowTo
If you want to add a new user to the vBulletin database, you can use Class vB_Datamanager_User.
This Calss does make sure that everything is OK, it will also take care of the default registration options.
showimages = Show Images, incl. attached Images and [img] BBCode
If this is not set they will show up as links
coppauser = User is COPPA User
adminemail = Receive Admin eMails
showvcard = Allow vCard Download
dstauto = Automatically detect DST setting
dstonoff = DST turned On
showemail = Receive eMails from other Users
invisible = Be invisible
showreputation = Show Reputation
receivepm = PM turned on
emailonpm = eMail notification for new PMs
Value must be 0 or 1 (false or true), depending if you want to set the option or not.
If the Options are not set, the Default Registration Options/Board Default Options will be used.
Important Notice
It is assumed that you are using this code from 'within' vBulletin, eg with the vBulletin backend loaded.
If this is not the case, you must include smth. like the following code in global context:
The ones I seem to be running into problems with are the ones below:
$newuser->set_bitfield('options', 'receivepm', '1');
--this dosn't seem to set the "Receive Private Messages" for the user to "Yes"
$newuser->set_bitfield('options', 'emailonpm', '1');
--this dosn't seem to set the "Send Notification Email When a Private Message is Received" for the user to "Yes"
Pop up a Notification Box When a Private Message is Received
--not sure what the option is to set this one?
This was a really good code that helped me integrate VB with my existing website.
Any idea if those functions will still work in 6.7?
I will wait for the final release of course of 6.7, but having this code working is a key factor for me to upgrade or not.
So if someone has tried this code on 6.7, please let us know.
Still running into problems with these as well as showimages
Anyone? Anyone lol
Quote:
Originally Posted by upnorth
The ones I seem to be running into problems with are the ones below:
$newuser->set_bitfield('options', 'receivepm', '1');
--this dosn't seem to set the "Receive Private Messages" for the user to "Yes"
$newuser->set_bitfield('options', 'emailonpm', '1');
--this dosn't seem to set the "Send Notification Email When a Private Message is Received" for the user to "Yes"
Pop up a Notification Box When a Private Message is Received
--not sure what the option is to set this one?
Fatal error: Registry object is not an object in [path]/includes/class_dm.php on line 177
#0 vb_error_handler(256, Registry object is not an object, /home/gymchat/public_html/messageboards/includes/class_dm.php, 177, Array ([this] => vB_DataManager_User Object ([validfields]
Quote:
Originally Posted by novastar
i use a modified version of the code they gave a couple posts back which works great for me.
Code:
<?php
$username="username";
$email="email@address.com";
$password="password";
$usergroupid="2";
$timezoneoffset="-6";
define('THIS_SCRIPT', 'remote_register.php');
chdir('/home/site/public_html/forum');
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', $username);
$userdm->set('email', $email);
$userdm->set('password', $password);
$userdm->set('usergroupid',$usergroupid);
$userdm->set('ipaddress', $ipaddress);
$userdm->set('timezoneoffset', $timezoneoffset);
$userdm->set_bitfield('options', 'adminemail', '1');
$userdm->set_bitfield('options', 'showemail', '1');
#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; $i<count($userdm->errors); $i++) {
print "ERROR{$i}:{$userdm->errors[$i]}\n";
}
} else {
# If everything is OK
$newuserid = $userdm->save();
print "vbuserid:$newuserid\n";
}
chdir('/home/site/public_html/');
?>
I would have taken more time to tinker with it, and possibilly put it in a function, but as there is only 1 place in my scripting but that works fine for me.
Im running it on vBulletin 3.6.2
This is the only auto-login/auto-register/integration information in all of support as far as I can tell. It is 3 years old and, while giving thanks to the author and noting that it is better than nothing, it hardly classifies as much more than a code snippet. I've seen dozens of posts on integration here that could be addressed by expanding and updating this information- surely it is not too much to ask?
--------------- Added [DATE]1211943709[/DATE] at [TIME]1211943709[/TIME] ---------------
Thank You!
--------------- Added [DATE]1211943812[/DATE] at [TIME]1211943812[/TIME] ---------------
Quote:
Originally Posted by coffeesgr
Anyone know how to fix error:
This did the trick for me
--------------- Added [DATE]1211943912[/DATE] at [TIME]1211943912[/TIME] ---------------
Thanks coffeesgr your code works #1 when executed directly; unfortunately it won't work when i use it inside a $_POST action.. please help.. what am I doing wrong ? here's my code below
Quote:
<?php
//Ajouter l'utilisateur dans la database du forum
if(isset($_POST['btn_update'])){
/*
$username=$_POST['username'];
$email=$_POST['email'];
$password=$_POST['password'];
$usergroupid=$_POST['usergroupid'];
$timezoneoffset="-5";
*/
$username="username";
$email="email@address.com";
$password="password";
$usergroupid="2";
$timezoneoffset="-5";
#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; $i<count($userdm->errors); $i++) {
print "ERROR{$i}:{$userdm->errors[$i]}\n";
}
}
else{
# If everything is OK
$newuserid = $userdm->save();
}
chdir('..');
}