vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=82836

Add new Users (automatically)
by Andreas
10 Jun 2005 16:11

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.

MrNase 10 Jun 2005 16:30

What does $newuser->errors look like? Is it an array() so that we have to use foreach ( ... AS ...) { } to display them?

Andreas 10 Jun 2005 16:34

Example (Username already taken):


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


Revan 10 Jun 2005 17:24

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

Marco van Herwaarden 10 Jun 2005 17:54

Quote:

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.

kall 15 Jun 2005 05:20

Quote:

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

N8 15 Jun 2005 05:59

I don't see the point in this, why not just create a new user via the admin cp?

Andreas 15 Jun 2005 06:03

Quote:

Originally Posted by N8_115
I don't see the point in this, why not just create a new user via the admin cp?

Quote:

Originally Posted by KirbyDE
As this is a common request for integration purposes,

Does this answer your question? :)

dwh 30 Jun 2005 00:37

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?

Andreas 30 Jun 2005 00:42

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.

dwh 30 Jun 2005 01:03

Quote:

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.

Xia 02 Jul 2005 12:38

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

tema 12 Jul 2005 11:51

Quote:

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?

merk 13 Jul 2005 01:41

Quote:

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.

scott8539 28 Oct 2005 21:45

Quote:

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


All times are GMT. The time now is 02:03.

Powered by vBulletin® Version 3.8.13
Copyright © 2019, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.