Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
Add new Users (automatically)
Andreas
Join Date: Jan 2004
Posts: 6,860

I am still alive ... unfortunately.

Germany
by Andreas Andreas is offline 10 Jun 2005

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

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

If there are errors (eMail not set, eMail banned, Username taken, etc.) you can check for errors using

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This is an array containing the errors.

If everything is OK

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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.)

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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.

Last edited by Andreas : 17 Aug 2008 at 16:38.
Views: 95740
Reply With Quote
Comments
  #2  
Old 10 Jun 2005, 16:30
MrNase's Avatar
MrNase MrNase is offline
 
Join Date: May 2003
Real name: Dominik
What does $newuser->errors look like? Is it an array() so that we have to use foreach ( ... AS ...) { } to display them?
Reply With Quote
  #3  
Old 10 Jun 2005, 16:34
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Real name: Andreas
Example (Username already taken):


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #4  
Old 10 Jun 2005, 17:24
Revan's Avatar
Revan Revan is offline
 
Join Date: Jan 2004
Real name: Fillip
Good, thanks for clarifying the array. I wrote my own error handler for the events I needed to output any errors, and it was a simple foreach that went like this:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The $error was then echoed out in the print_standard_error.

Btw while Im at it, if we need to for instance add 2 users with different values, or send 2 pms, do we need to put the
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

line every time? Also do the variable names have to be different for those 2 instances?

TIA
Reply With Quote
  #5  
Old 10 Jun 2005, 17:54
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Originally Posted by MrNase
What does $newuser->errors look like? Is it an array() so that we have to use foreach ( ... AS ...) { } to display them?
Please read the stickied post in the top of this forum.
__________________
Marco van Herwaarden
Ex vBulletin.org Coordinator
Reply With Quote
  #6  
Old 15 Jun 2005, 05:20
kall's Avatar
kall kall is offline
 
Join Date: Apr 2004
Real name: Ace
Originally Posted by MarcoH64
Please read the stickied post in the top of this forum.
So...we aren't allowed to ask questions in these How-to threads, is that what you are referring to the sticky thread for?

Seems a bit strange to me...surely that thread is meaning 'Don't Start question threads'.
__________________
vBulletin Styles (All styles compatible with 3.8.4 - Steel Blue 4.0 Available) | vBulletin Hosting
Reply With Quote
  #7  
Old 15 Jun 2005, 05:59
N8's Avatar
N8 N8 is offline
 
Join Date: Dec 2004
Real name: Nathan
I don't see the point in this, why not just create a new user via the admin cp?
__________________
N8
Used Oilfield Equipment | Hydraulic Catwalk
Reply With Quote
  #8  
Old 15 Jun 2005, 06:03
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Real name: Andreas
Originally Posted by N8_115
I don't see the point in this, why not just create a new user via the admin cp?
Originally Posted by KirbyDE
As this is a common request for integration purposes,
Does this answer your question?
Reply With Quote
  #9  
Old 30 Jun 2005, 00:37
dwh's Avatar
dwh dwh is offline
 
Join Date: Feb 2002
What if you want to create a new user, assign him

$newuser->set('usergroupid', 10);



but you'd like his email verified first through the usual system and once he gets verified then he's placed in 10?

EDIT: I keep clicking on the black font color, in this screen the above text turns black. I hit enter, it reverts to green?

Last edited by dwh : 30 Jun 2005 at 00:40.
Reply With Quote
  #10  
Old 30 Jun 2005, 00:42
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Real name: Andreas
You would have t hook into register_activate_process and change the Usergroupid there.

Anyway, the described method does not generate an activation ID and such.
If you are interested in this I can write up some description.
Reply With Quote
  #11  
Old 30 Jun 2005, 01:03
dwh's Avatar
dwh dwh is offline
 
Join Date: Feb 2002
Originally Posted by KirbyDE
You would have t hook into register_activate_process and change the Usergroupid there.

Anyway, the described method does not generate an activation ID and such.
If you are interested in this I can write up some description.
I will be using the activation ID eventually and it would be very helpful. But I'm in no urgent rush at all for this.
Reply With Quote
  #12  
Old 02 Jul 2005, 12:38
Xia Xia is offline
 
Join Date: Mar 2005
What files need to be included to get this to work?

I don't see the function datamanager_init in class_dm_user.php

Thanks
Reply With Quote
  #13  
Old 12 Jul 2005, 11:51
tema tema is offline
 
Join Date: Jun 2004
Originally Posted by KirbyDE
Anyway, the described method does not generate an activation ID and such.
If you are interested in this I can write up some description.
Ok, can u describe how to make user whith waiting for activation with emailing of that?
Reply With Quote
  #14  
Old 13 Jul 2005, 01:41
merk merk is offline
 
Join Date: Nov 2001
Real name: Tim
Originally Posted by MarcoH64
Please read the stickied post in the top of this forum.
I cant imagine that this falls under the "dont ask questions". This question was specific to this howto about improving it with the format of a mentioned error variable.
Reply With Quote
  #15  
Old 28 Oct 2005, 21:45
scott8539 scott8539 is offline
 
Join Date: Oct 2005
Originally Posted by Andreas
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

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

.....

Perhaps I am missing something...but I cannot get the above code to work. Could you provide a complete, self contained script that can be executed on the cmd line (or exec'd or remote require'd from another program)? I have searched through this forum and found examples of creating a thread , but this is the only code reference to creating a user --- which is exactly what I am after!

My goal in this is to have my own CMS manage the registration: The user will register in my CMS (custom designed CMS -- this is not a 3rd party off-the-shelf CMS), then call a script to add the user to the forum.

Thanks!

-Scott
vB 3.5

Last edited by scott8539 : 28 Oct 2005 at 23:37.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Article Options

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


New To Site? Need Help?

All times are GMT. The time now is 05:38.

Layout Options | Width: Wide Color: