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. |
What does $newuser->errors look like? Is it an array() so that we have to use foreach ( ... AS ...) { } to display them?
|
Example (Username already taken):
Code:
Array |
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:
PHP Code:
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 PHP Code:
TIA :) |
Quote:
|
Quote:
Seems a bit strange to me...surely that thread is meaning 'Don't Start question threads'. |
I don't see the point in this, why not just create a new user via the admin cp?
|
Quote:
Quote:
|
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? |
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. |
All times are GMT. The time now is 08:32 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|