Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Add new Users (automatically)
Andreas's Avatar
Andreas
Join Date: Jan 2004
Posts: 6,863

 

Germany
Show Printable Version Email this Page Subscription
Andreas Andreas is offline 06-09-2005, 10:00 PM

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:
$newuser =& datamanager_init('User'$vbulletinERRTYPE_ARRAY);
$newuser->set('username''phpNukeUser');
$newuser->set('email''foo@bar.com');
$newuser->set('password''verysecret');
$newuser->set('usergroupid'2); 
If there are errors (eMail not set, eMail banned, Username taken, etc.) you can check for errors using
PHP Code:
$newuser->errors 
This is an array containing the errors.

If everything is OK
PHP Code:
$newuserid $newuser->save(); 
This will create a new User called phpNukeNuser (UserID returned in $newuserid).

You can also set many other info too:
  • membergroupids = comma-separated string of all additional usergroups (Default=Empty)
  • displaygroupid = ID of the usergroup this user should show up as (Default=0)
    Note that this must be set after usergroupid and membergroupids!
  • styleid = ID of the Style to be used by this user (Default=Board Default)
  • languageid = ID of the language to be used by this user (Default=Board Default)
  • threadedmode = Whether to use Flat (0), Hybrid (1) or Threaded (2) Display Mode
  • maxposts = Integer, how many posts should be shown on one Page (Default=Board Default)
  • ipaddress = String, IP-Adress of the User registering (Default=Empty)
  • refererid = String, Username or UserID of the User this user was refered by
  • parentemail = String. eMail-Address of the users Parents
  • daysprune = Integer, show threads from the last X days
  • startofweek = Integer, When does the week start (1=Sunday, 2=;onday, ...) (Default=Board Default)
  • timezoneoffset = Integer, spexifying the Timezone (-12 .. +12)
  • autosubscribe = Integer, defining default mode for Thread subscription
    -1 = no Subscription, 1 = Instant, 2 = Daily Digest, 3 = Weekly Digest
    (Default=Board Default)
  • homepage = String, URL of the users Homepage (Default=Empty)
  • icq = String, the Users ICQ # (Default=Empty)
  • aim = String, the Users AIM ID (Default=Empty)
  • yahoo = String, the Users Yahoo ID (Default=Empty)
  • MSN = String, the Users MSN ID (Default=Empty)
  • usertitle = String, the Usertitle this user should have
  • customtitle = Integer, defining behaviour of Usertitle. 0=No Custom Title, 1=Custom, Title with HTML, 2=Custom Title without HTML (Default=
  • birthday = array(month, day, year). The users birthdate.
  • avatarid = Integer, ID of the Avatar being used for this user
  • signature = String. The Users Signature
  • subfolders = Array. The Users Subscription Folders
  • pmfolders = Array. The Users Subscription Folders
  • buddylist = String. Space separated List of UserIDs defining the Users buddylist
  • ignorelist = String. Space separated List of UserIDs defining the Users ignorelist

Besides that, you can also set the options Bitfield (Receive Admin PMs, etc.)
PHP Code:
$userdata->set_bitfield('options''optionname''value'); 
The available Options are
  • showsignatures = Show Signatures
  • showavatars = Show Avatars
  • 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:
PHP Code:
define('VB_AREA''External');
define('SKIP_SESSIONCREATE'1);
define('SKIP_USERINFO'1);
define('CWD''/path/to/vbulletin');
require_once(
CWD '/includes/init.php'); 
Keep in mind that if you are using the a/m Datamanager-Code within a function or method you must global $vbulletin.

This How-To is (C) 2005 by KirbyDE and you are not allowed to redistribute it in any way without my explicit consent.
Reply With Quote
  #52  
Old 04-24-2007, 01:45 AM
Ba$im Ba$im is offline
 
Join Date: Apr 2007
Location: Saudi Arabia
Posts: 167
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i dont know how do it?
let c what i can understand
first creat vB_Datamanager_User.php file then put this code and upload to vb folder in your site
then
ask this
http://yoursite/vb/vB_Datamanager_User.php
it just registerd 1 user???
and i should change username and email again and reupload???

how it does automatically???

can any one help me how do this plz
Reply With Quote
  #53  
Old 04-27-2007, 04:56 PM
Spandauer Spandauer is offline
 
Join Date: Aug 2005
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi everybody,

is it also possible to pass a simple URL to a script, which takes the variables from the URL and registers the new user? The problem is, that i dont have the possibility to send something else... the only thing i can do for my project is sending an URL... will it be possible?
Reply With Quote
  #54  
Old 04-30-2007, 11:09 PM
Poc1984 Poc1984 is offline
 
Join Date: Apr 2007
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is it possible to use this and pass in a password that is already an md5 hash?

for example:

$userdm->set('password', "5f0f8c991d3d31c63ab531916c298c65");
Reply With Quote
  #55  
Old 06-28-2007, 11:45 PM
Ba$im Ba$im is offline
 
Join Date: Apr 2007
Location: Saudi Arabia
Posts: 167
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

plz some 1 tell me how do that?
Reply With Quote
  #56  
Old 07-04-2007, 02:42 PM
mpage mpage is offline
 
Join Date: Aug 2006
Posts: 62
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Spandauer View Post
Hi everybody,

is it also possible to pass a simple URL to a script, which takes the variables from the URL and registers the new user? The problem is, that i dont have the possibility to send something else... the only thing i can do for my project is sending an URL... will it be possible?
Yuo would just have to pass the variable to the cURL or modified script above via the _GET method . The cURL would then post this to the datamanager, Im just about to set this up myself, so Im no expert.

I will also have to use the modified method above since I cant install curl on my host.

I cant belive this isnt made easyier (for external sign ups)

Quote:
Originally Posted by djdrey View Post
You don't have to use CURL to do it, but you have to include globals.php in your script root if you want to create the user from within a function or method.

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!


How can you have globals.php in your script root for a 2nd host/server/url, unless its coppied over, or the registration code is also in the root of forum.

Hmm, Ill look into this!
Reply With Quote
  #57  
Old 07-05-2007, 05:51 PM
thbertram thbertram is offline
 
Join Date: Sep 2006
Location: Arkansas US
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is making driving me batty... With the "save" line commented, no errors are found. When I uncomment it, the data gets saved, BUT the error message line executes as if the entire program reruns itself. The 2 errors generated are duplicate username and duplicate email. Anyone have any ideas?

Code:
$userdata =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY); 
$userdata->adminoverride = true;

$userdata->set('username', 'phpNukeUser'); 
$userdata->set('email', 'foo@bar.com'); 
$userdata->set('password', 'verysecret'); 
$userdata->set('usergroupid', 500);
$userdata->set('usertitle','Tourist');

if(count($userdata->errors))
{
	echo "<b>".count($userdata->errors) . " errors </b>";
}
else
{
//	$uid = $userdata->save();
	echo "<br/>User " . $uid . " added.";
}
Reply With Quote
  #58  
Old 07-19-2007, 12:03 AM
Searchworm1 Searchworm1 is offline
 
Join Date: Dec 2006
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

My God - the curl thing worked. It took me all week to find this post. Thanks.
Reply With Quote
  #59  
Old 07-19-2007, 05:24 PM
beejeebers beejeebers is offline
 
Join Date: Jul 2007
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Novastar's script worked beautifully on the first try!

Thanks dude.

Reply With Quote
  #60  
Old 07-23-2007, 08:36 PM
mpage mpage is offline
 
Join Date: Aug 2006
Posts: 62
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

anyone having trouble with new users not getting a welcome post via datamanager, no idea how to make sure new users get a welcome post, there must be a way
Reply With Quote
  #61  
Old 07-31-2007, 02:55 PM
RonInMaine RonInMaine is offline
 
Join Date: Jul 2007
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

When I use any variations of the scripts (with cURL and without) in this thread, I get these errors:

Notice: Undefined index: HTTPS in /var/www/html/includes/class_core.php on line 1599
Notice: Undefined index: HTTPS in /var/www/html/includes/class_core.php on line 1599
Notice: Undefined index: HTTP_REFERER in /var/www/html/includes/class_core.php on line 1626

I'm using VB 3.6.7 -- has something changed in this version that might be causing this? Is there another file I need to include to get the environment set up right?

I see where these indices are used in class_core.php, but I haven't (yet) found where they are defined. Still looking ...

Any suggestions would be appreciated.

Thanks,
Ron.

Okay, I'm not thinking straight. Of course, php sets the $_Server superglobal. SO, I guess my job is to find out why the HTTPS and HTTP_REFERER values are not being set.

Thanks,
Ron.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:14 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05227 seconds
  • Memory Usage 2,320KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (5)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete