The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Add new Users (automatically)
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. Example PHP Code:
PHP Code:
If everything is OK PHP Code:
You can also set many other info too:
Besides that, you can also set the options Bitfield (Receive Admin PMs, etc.) PHP Code:
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: PHP Code:
This How-To is (C) 2005 by KirbyDE and you are not allowed to redistribute it in any way without my explicit consent. |
#42
|
|||
|
|||
thanks a million for this script cause I really needed it
it works like a charm |
#43
|
||||
|
||||
I'd really like to be able to set the cookie and log the user in after they are instantly registered. Any ideas?
|
#44
|
|||
|
|||
i agree wtih bradsears. can anyone shed some light on how to automatically log in a user?
do we just set the cookies and that's it? |
#45
|
|||
|
|||
I recently added a field to the user profile (gender)
I also renamed location to country I would like to be able to automatically set these fields similarly to the other fields in the above example. Im unclear as to how this would be possible. Any help would be greatly appreciated. |
#46
|
|||
|
|||
Quote:
You also have to remember to retrieve the global vbulletin variable to pass into the datamanager class. I spent the last few hours working that out, hopefully it'll help someone else! |
#47
|
|||
|
|||
Thanks. Would you mind posting the code you used?
|
#48
|
|||
|
|||
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/'); ?> Im running it on vBulletin 3.6.2 |
#49
|
|||
|
|||
Hello,
i use the code it's work fine but i have one problem. I can login the user but when i in the admincp and i edit the user i dont see any username in the inputfield! What is wrong? Raiden |
#50
|
|||
|
|||
Its possible verify if the usergroup exists before add to database the new user?
Exemple, to test I set the usergroup to 2000000 and VB ignore and inserted the user normally. ps: same problem with password field, I set like empty and vbulletin inserted the data.. |
#51
|
|||
|
|||
Hello All,
I'm using the following code, posted by Brad Sears, for sending out activation emails after adding a user via the script on this thread: PHP Code:
It works, sort of. The only problem is that the email does not contain the username of the user being emailed (it begins "Welcome, (blank)"). The userid in the links and the email address it sends to are correct, but no username... Do I need to pass additional variables to these functions? Thanks! Tim |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|