PDA

View Full Version : Add new Users (automatically)


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


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



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


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------


This is an array containing the errors.

If everything is OK


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



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


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



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:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



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



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

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:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

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

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

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
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
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
I don't see the point in this, why not just create a new user via the admin cp?

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


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



.....


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 (http://www.vbulletin.org/forum/showthread.php?t=97283) , 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

J75595E3F40B
03 Nov 2005, 21:46
yes I also cannot get the script above to work.. do I need to initialize $vbulletin via a constructor?

Psionic Vision
03 Nov 2005, 22:07
yes I also cannot get the script above to work.. do I need to initialize $vbulletin via a constructor?

The script works as long as you use it on a vbulletin-powered page.

J75595E3F40B
03 Nov 2005, 22:22
What would be necessary to use the user data-manager from outside a vbulletin-powered page?

Andreas
03 Nov 2005, 23:11
The vBulletin backend, which makes it a vBulletin powered page :)

scott8539
03 Nov 2005, 23:46
I finally got a working script to add a user to vB offline. I maintain a separate Membership System. When a user registers in this separate system, an account is automatically created for them in vB.

When they register (again, this is in my own Member System -- on a different domain), I collect those variables that I need specifically (and minimally) to create an account in vB.

I then cURL those variables to a custom script (called bb_add_user.php) which resides in the root folder of the forum. The results of bb_add_user.php are printed, which are then collected in the result of the cURL. If there are errors, the Membership System takes appropriate action. If successul, then I grab the vbuserid from the cURL result and go about my business.

Although I am still proving this system on a development server, my goal will be to change all of the 'register.php' links on vBulletin and point them to the register script on my Membership System.

Here is the bb_add_user.php code.



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

Psionic Vision
03 Nov 2005, 23:48
You shouldn't use CURL, as vBulletin data managers have data verifiers of their own. Just supply the raw values...

scott8539
03 Nov 2005, 23:53
You shouldn't use CURL, as vBulletin data managers have data verifiers of their own. Just supply the raw values...

I am not sure what you mean by supplying the raw values...that is pretty much what I am doing with cURL. What would be another way of supplying the values?

Wayne Luke
04 Nov 2005, 00:11
Can anyone write a proof of concept on how this would be done? I mean a complete file that would accept POST values from another page, instantiate the manager and create the user?

Psionic Vision
04 Nov 2005, 00:53
Of course. Except the official vB documentation provides all the information of this matter... At least about using GPC for POST values....

J75595E3F40B
04 Nov 2005, 16:08
i got a script working that does the same thing, and i noticed one thing..... that script must be in the same directory as global.php

Dark_Wizard
05 Nov 2005, 12:07
i got a script working that does the same thing, and i noticed one thing..... that script must be in the same directory as global.php


Uhmm...incorrect. Try this piece from Dark Visor here about outside of vBulletin pages -> Using vBulletin-powered scripts outside vBulletin Directory (http://www.vbulletin.org/forum/showpost.php?p=791513&postcount=1).

Connector
27 Dec 2005, 21:54
I finally got a working script to add a user to vB offline. I maintain a separate Membership System. When a user registers in this separate system, an account is automatically created for them in vB.

When they register (again, this is in my own Member System -- on a different domain), I collect those variables that I need specifically (and minimally) to create an account in vB.

I then cURL those variables to a custom script (called bb_add_user.php) which resides in the root folder of the forum. The results of bb_add_user.php are printed, which are then collected in the result of the cURL. If there are errors, the Membership System takes appropriate action. If successul, then I grab the vbuserid from the cURL result and go about my business.

Although I am still proving this system on a development server, my goal will be to change all of the 'register.php' links on vBulletin and point them to the register script on my Membership System.

Here is the bb_add_user.php code.



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




could someone please tell me how could we use this code ? i try it and give me error :devious:

scott8539
27 Dec 2005, 22:09
could someone please tell me how could we use this code ? i try it and give me error :devious:

Geez, that was a long time ago and I have taken a completely different approach to it.

I do have my own way of creating a vB account from an external site. In fact, I just went live with it today.

forum.bodybuilding.com (http://forum.bodybuilding.com)

If you click the register link, you will be redirected to a register script on a different site (my.bodybuilding.com -- different subdomain). There you enter your user information and submit. A new user is created in my Membership System, then the user is created in vBulletin.

The register, login/logoff, activation, recover lost password, edit email & password, etc, are are handled in my separate Membership System, pushing the results to vBulletin.

macks
29 Dec 2005, 05:21
I am in the process of writing a user signup integration script. My forum runs on a separate server from my main site. I am going to need to write hooks in quite a few places. I've compiled a list of the spots where I will need to have remote vB hooks.

Initial user signup:
Add the user, put them in the email confirmation group. (my site sends a confirmation email).

Confirmation:
When the user clicks the link in the confirmation email.

Password and email changes:
When the user wants to change their email or password.

This will all need to be done from a remote server so I too will most likely be using cURL. Obviously I want to keep these changes in sync. It isn't fully clear to me if it would be easier to write a plugin with change password/email hooks that will update my system or if I should just deny these changes from the vBulletin side and change the permission denied template to point to the proper place on my site.

Once I've hammered through the few remaining issues, I will post my results and code here.

Geez, that was a long time ago and I have taken a completely different approach to it.

I do have my own way of creating a vB account from an external site. In fact, I just went live with it today.

forum.bodybuilding.com (http://forum.bodybuilding.com)

If you click the register link, you will be redirected to a register script on a different site (my.bodybuilding.com -- different subdomain). There you enter your user information and submit. A new user is created in my Membership System, then the user is created in vBulletin.

The register, login/logoff, activation, recover lost password, edit email & password, etc, are are handled in my separate Membership System, pushing the results to vBulletin.

Woops, just read your post and you seem to be describing everything I just mentioned. Care to give the rest of an idea of how long it took?

Connector
29 Dec 2005, 14:21
Could someone put basic code how to do this ?

GrowersPro
05 Jan 2006, 04:47
following code place earlier plus example of code for the curl call in php


STEP I

this file need to to be placed in the forum directory of vbulletin
(make sure it is in this directory to initialise vbulletin stuff ......)


no change done from previous poster


you can include the code below in one php page. call it whatever you want

i call it great_stuff_dude.php

thus i need to MAKE sure that the name of the page is correctly entered
in the define below

define('THIS_SCRIPT', 'GREAT_STUFF_DUDE.php');

do the same in the code below
----------------------------------------------------------------------
<?php
# Add a user to vBulletin (offline)

function qpc_post($varname)
{
return trim(stripslashes((get_magic_quotes_gpc()) ? $_POST[$varname] : addslashes($_POST[$varname])));
}

define('THIS_SCRIPT', 'GREAT_STUFF_DUDE.php');

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', qpc_post('username'));
$userdm->set('email', qpc_post('email'));
$userdm->set('password', qpc_post('password'));
$userdm->set('usergroupid',qpc_post('usergroupid'));
$userdm->set('ipaddress', qpc_post('ipaddress'));
$userdm->set('referrerid', qpc_post('referrername'));
$userdm->set('timezoneoffset', qpc_post('timezoneoffset'));
$userdm->set_bitfield('options', 'adminemail', intval(qpc_post('adminemail')));
$userdm->set_bitfield('options', 'showemail', intval(qpc_post('showemail')));

$dst_setting = intval(qpc_post('dst'));
switch ($dst_setting)
{
case 0:
case 1:
$userdm->set_bitfield('options', 'dstonoff', $dst_setting);
break;
case 2:
$userdm->set_bitfield('options', 'dstauto', 1);
break;
}

#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";
}
?>
-------------------------------------------------------------------


STEP II



You can have the following code on server running PHP WHEREVER YOU WANT. it does not need to be on the same domain as long as you have the curl compiled


in that script (again call it whatever you want it does not matter)

you call the url of your web server and path to go to the page GREAT_STUFF_DUDE.php

you can of course include it in the login code of your CMS to create profiles in both systems in one step.


-------------------------------------------------------------------

<?php

$url="http://www.mysite.com/vbulletin3000/GREAT_STUFF_DUDE.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "username=keith_mayass&email=keith_mayass@no_worrys.com&password=up_yours&usergroupid=2&");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
$content = curl_exec ($ch); # This returns HTML
curl_close ($ch);

?>
---------------------------------------------------------

you can of course pass as may variables as you want if you have them available in your CMS to complete the profile.

like

parentemail
showbirthday
homepage
icq
aim
yahoo
msn
skype
usertitle
customtitle
birthday



__-----__________------___
Ni vu ni connu, jt' embrouille

Langly
07 Jan 2006, 22:12
I use Postnuke, so which file in Postnuke to I put the curl code in and where in the file?

Connector
11 Jan 2006, 07:12
This code dose not work i try it and give me error please Help :*

Langly
11 Jan 2006, 13:00
Thread might be dead.

bkbelew
16 Mar 2006, 19:06
Any update on this? I managed to add a user to the Vb database w/ just a couple simply mysql calls. But.... the password encryption was wrong ( i'm assuming ) it wouldn't allow the user to login. BUT if the user went through the lost password function, it would allow them to. Could someone help me w/ the command to encrypt the password w/ salt or whatever its using to add it into my database w/out having to hook anything from vb?

Thanks

Fume
30 Mar 2006, 19:44
If you click the register link, you will be redirected to a register script on a different site (my.bodybuilding.com -- different subdomain). There you enter your user information and submit. A new user is created in my Membership System, then the user is created in vBulletin.

The register, login/logoff, activation, recover lost password, edit email & password, etc, are are handled in my separate Membership System, pushing the results to vBulletin.
I'm looking for something exactly like that! Anyone know how I would accomplish this? :banana:

Altec
15 May 2006, 12:52
I've managed to automatically add users to vBulletin via our website which is done in ASP. The only issue I'm having is that a user cannot 'SAVE' their signature (strange). Everything else works great...

Anyone have any ideas why?

Thanks.

Connector
15 May 2006, 15:28
Why you have make it in ASP and not php ?

bigtime
30 May 2006, 23:38
How would a new user be added without using curl?

Thanks,

Tim

bradsears
08 Jun 2006, 21:51
Hi. I'd like to be able to send the registration email after the user registers. How do I do this. Thanks in advance.

-- edit --

I answered this one myself

$activateid = build_user_activation_id($newuserid, 2, 0);
eval(fetch_email_phrases('activateaccount'));
vbmail($email, $subject, $message, true);

asphix
21 Jun 2006, 19:50
thanks a million for this script cause I really needed it
it works like a charm

bradsears
21 Jun 2006, 19:53
I'd really like to be able to set the cookie and log the user in after they are instantly registered. Any ideas?

scorinaldi
10 Jul 2006, 07:48
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?

workRelated
27 Jul 2006, 02:13
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.

djdrey
05 Oct 2006, 03:49
How would a new user be added without using curl?

Thanks,

Tim

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!

bigtime
05 Oct 2006, 03:52
Thanks. Would you mind posting the code you used?

novastar
27 Oct 2006, 04:59
i use a modified version of the code they gave a couple posts back which works great for me.


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



I would have taken more time to tinker with it, and possibilly put it in a function, but as there is only 1 place in my scripting but that works fine for me.
Im running it on vBulletin 3.6.2

XxRaidenxX
22 Dec 2006, 10:25
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

testebr
23 Dec 2006, 14:24
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..

timedgar
13 Feb 2007, 02:06
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:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




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

Ba$im
24 Apr 2007, 03:45
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

Spandauer
27 Apr 2007, 18:56
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?

Poc1984
01 May 2007, 01:09
Is it possible to use this and pass in a password that is already an md5 hash?

for example:

$userdm->set('password', "5f0f8c991d3d31c63ab531916c298c65");

Ba$im
29 Jun 2007, 01:45
plz some 1 tell me how do that?

mpage
04 Jul 2007, 16:42
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 (http://www.w3schools.com/php/php_get.asp)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)

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!

thbertram
05 Jul 2007, 19:51
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:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

Searchworm1
19 Jul 2007, 02:03
My God - the curl thing worked. It took me all week to find this post. Thanks.

beejeebers
19 Jul 2007, 19:24
Novastar's script worked beautifully on the first try!

Thanks dude.

:)

mpage
23 Jul 2007, 22:36
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

RonInMaine
31 Jul 2007, 16:55
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.

Marco van Herwaarden
31 Jul 2007, 18:28
Add the following to the top of your script:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

RonInMaine
31 Jul 2007, 18:57
Thank you. That worked nicely.

But, now you've got me curious. How did changing the error reporting options fix the problem?

Thanks,
Ron.

psalzmann
09 Aug 2007, 07:02
Brilliant! Thanks Novastar!

blogtorank
12 Aug 2007, 08:40
I've made it possible for you all to start creating members automatically here in this new hack:

http://www.vbulletin.org/forum/showthread.php?t=154637

I branched differently with all full sources of .NET and PHP using what I seen on the forums here with my .NET, and putting it all to work within XML_RPC I hope this helps others out as well.

psalzmann
15 Aug 2007, 04:52
We are using novastar's hack as mentioned above and it's working fine. However, adding users is one thing, updating is another .. which brings me to my next question:

Will this work to actually "update" an existing user, all we're trying to do is update an existing user in the forum to a new usergroup:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



But before I execute and implement that code above, I just want to make sure this won't actually "insert/register or create" a user, I would like to just update.

Any clues? is there a $userdm->update(); instead of save? I noticed a pre_save() option and now it's got me a bit curious :)

Thanks in advance!

Okay I did some more reading.. would someone be able to verify the following code:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



TIA

blogtorank
15 Aug 2007, 05:22
We are using novastar's hack as mentioned above and it's working fine. However, adding users is one thing, updating is another .. which brings me to my next question:


Not off hand I don't think there is anything that can make it update without modifying the code to make it UPDATE, unless you make the set work as an update within a sql statement inside your PHP code....

taras
06 Sep 2007, 04:06
Hey novastar
How do you pass varibles from another DB?
we tryed:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



But it's not working...



i use a modified version of the code they gave a couple posts back which works great for me.


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



I would have taken more time to tinker with it, and possibilly put it in a function, but as there is only 1 place in my scripting but that works fine for me.
Im running it on vBulletin 3.6.2

skattabrain
08 Oct 2007, 16:33
novastar ... added user without trouble, thanks!

any ideas on how to add the custom field data?

amatulic
13 Oct 2007, 06:16
After much testing and examining vBulletin code, I finally finished my PHP class for performing basic operations on user accounts (create user, modify user, delete user, log on, log off). This has enabled me to integrate the forum into my site. Users who log in to my site are logged in to the forum, users who register on my site automatically get an account on the forum, etc.

Once that was done, I just had to modify all the vBulletin templates that contained a login form, logout link, register link, or user account modification link, and make sure those things use MY code for those functions. Now users can log in either from the forum or from my main site, and user account registration and modification are all handled on my main site, outside of the forum. It all works pretty well, without modifying a single line of the vBulletin source code.

Here is the code for class.forumops.php, with extensive usage comments:

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------


As you can see, most of the operations above are pretty simple, except for the user deletion function. Also, to update user account information, see the first post of this thread for options you can use.

The wordwrapping above looks funny, but if you quote this message as if to reply, the wordwrapping will be correct when you copy and paste it.

I hope this helps some people.
-Alex

Lordy
14 Oct 2007, 21:47
When using your code (amatulic), I get
Fatal error: Call to a member function query_first() on a non-object in /home/lordy/domains/animefill.com/public_html/project/forum/includes/class_dm_user.php on line 380

I'm passing the variables this way



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------


line 380 is


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

amatulic
15 Oct 2007, 04:20
When using your code (amatulic), I get "Fatal error: Call to a member function query_first() on a non-object in /home/lordy/domains/animefill.com/public_html/project/forum/includes/class_dm_user.php on line 380"
Odd. It's working for me. Try this hard-coded example, in the same directory where you have class.forumops.php. You can run it from the commandline:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

You can go to the admin control panel "Prune / Move Users" and verify the user account 'test_user' got created. I just did a diff of what I posted vs what I have, and the only difference I see is that I am now passing the username by reference to delete_user(). That shouldn't make any difference. I'll update my source in my previous message anyway.
-Alex

Lordy
17 Oct 2007, 22:16
Yup, seems that that does work. Can't seem to figure out how to do.

I tried putting


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

in my config file, and just including it. I think i'll probably have to code around that as it seems its setting some issues

I'll have to debug this on my end it seems.

I think I may have figured it out.

thanks =) I'll post back when I have a definite answer.

Lordy
19 Oct 2007, 02:26
Recoded my reg form and it works fine now. Can't seem to work out the login form, so I looked at your login script.



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------


which i'm assuming is that? if so, passing as $forum->login($userdata) is not working for me, but looking through your code, I also don't know if that does work.

A58676333470
20 Oct 2007, 02:06
Weee! EXACTLY what im looking for @amatulic ! Works Perfect! Thx!

SolidSlug
24 Nov 2007, 07:32
amatulic,

Your code works great from a PHP page that has no other includes, but as soon as I plugged it into my own CMS, I got the dreaded:

PHP Fatal error: Call to a member function query_first_slave() on a non-object in /var/www/html/papatangopapa.com/forums/includes/functions.php on line 1194

My CMS has its own session management stuff and also uses a custom __autoload function, I wonder if that breaks things in some weird way.

--------------- Added 1195925781 at 1195925781 ---------------

I think it's due to vBulletin's insane reliance on global variables.

When you have:

A.php including init.php and functions.php directly,

there is no problem.

When you have:

a function in B.php including including C.PHP, which includes init.php and functions.php,

you get:

PHP Fatal error: Call to a member function query_first_slave() on a non-object in /var/www/html/papatangopapa.com/forums/includes/functions.php on line 1194

--------------- Added 1195926210 at 1195926210 ---------------

That's also how and why you might end up using cURL in order to keep your application and the namespace polluting vBulletin back-end completely separate.

stoppy
25 Nov 2007, 23:24
Hi!
I'm using 3.6.8 version, I'm trying to add user to vb using my own registration system.

The constructor of the class I have take 2 parameters in input

function vB_DataManager_User(&$registry, $errtype = ERRTYPE_STANDARD)

How I have to use it?

May I include directly this class in my code... it look like not... How can I do?

I proposed another way to solve this problem here: http://www.vbulletin.org/forum/showthread.php?p=1389327#post1389327

Thanks

Moooooon
01 Dec 2007, 22:55
Would this approach still work in 3.6.8?

following code place earlier plus example of code for the curl call in php


STEP I

this file need to to be placed in the forum directory of vbulletin
(make sure it is in this directory to initialise vbulletin stuff ......)


no change done from previous poster


you can include the code below in one php page. call it whatever you want

i call it great_stuff_dude.php

thus i need to MAKE sure that the name of the page is correctly entered
in the define below

define('THIS_SCRIPT', 'GREAT_STUFF_DUDE.php');

do the same in the code below
----------------------------------------------------------------------
<?php
# Add a user to vBulletin (offline)

function qpc_post($varname)
{
return trim(stripslashes((get_magic_quotes_gpc()) ? $_POST[$varname] : addslashes($_POST[$varname])));
}

define('THIS_SCRIPT', 'GREAT_STUFF_DUDE.php');

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', qpc_post('username'));
$userdm->set('email', qpc_post('email'));
$userdm->set('password', qpc_post('password'));
$userdm->set('usergroupid',qpc_post('usergroupid'));
$userdm->set('ipaddress', qpc_post('ipaddress'));
$userdm->set('referrerid', qpc_post('referrername'));
$userdm->set('timezoneoffset', qpc_post('timezoneoffset'));
$userdm->set_bitfield('options', 'adminemail', intval(qpc_post('adminemail')));
$userdm->set_bitfield('options', 'showemail', intval(qpc_post('showemail')));

$dst_setting = intval(qpc_post('dst'));
switch ($dst_setting)
{
case 0:
case 1:
$userdm->set_bitfield('options', 'dstonoff', $dst_setting);
break;
case 2:
$userdm->set_bitfield('options', 'dstauto', 1);
break;
}

#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";
}
?>
-------------------------------------------------------------------


STEP II



You can have the following code on server running PHP WHEREVER YOU WANT. it does not need to be on the same domain as long as you have the curl compiled


in that script (again call it whatever you want it does not matter)

you call the url of your web server and path to go to the page GREAT_STUFF_DUDE.php

you can of course include it in the login code of your CMS to create profiles in both systems in one step.


-------------------------------------------------------------------

<?php

$url="http://www.mysite.com/vbulletin3000/GREAT_STUFF_DUDE.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "username=keith_mayass&email=keith_mayass@no_worrys.com&password=up_yours&usergroupid=2&");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
$content = curl_exec ($ch); # This returns HTML
curl_close ($ch);

?>
---------------------------------------------------------

you can of course pass as may variables as you want if you have them available in your CMS to complete the profile.

like

parentemail
showbirthday
homepage
icq
aim
yahoo
msn
skype
usertitle
customtitle
birthday



__-----__________------___
Ni vu ni connu, jt' embrouille

makouvlei
06 Dec 2007, 21:59
I've managed to automatically add users to vBulletin via our website which is done in ASP. The only issue I'm having is that a user cannot 'SAVE' their signature (strange). Everything else works great...

Anyone have any ideas why?

Thanks.

I am looking to implement a similar system managing vBulletin users from an asp site. I'm very comfortable with asp, but not at all with php -- any pointers as to how to (and how not to) approach this would be much appreciated.

jazeera
10 Dec 2007, 13:39
following code place earlier plus example of code for the curl call in php


STEP I

this file need to to be placed in the forum directory of vbulletin
(make sure it is in this directory to initialise vbulletin stuff ......)


no change done from previous poster


you can include the code below in one php page. call it whatever you want

i call it great_stuff_dude.php

thus i need to MAKE sure that the name of the page is correctly entered
in the define below

define('THIS_SCRIPT', 'GREAT_STUFF_DUDE.php');

do the same in the code below
----------------------------------------------------------------------
<?php
# Add a user to vBulletin (offline)

function qpc_post($varname)
{
return trim(stripslashes((get_magic_quotes_gpc()) ? $_POST[$varname] : addslashes($_POST[$varname])));
}

define('THIS_SCRIPT', 'GREAT_STUFF_DUDE.php');

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', qpc_post('username'));
$userdm->set('email', qpc_post('email'));
$userdm->set('password', qpc_post('password'));
$userdm->set('usergroupid',qpc_post('usergroupid'));
$userdm->set('ipaddress', qpc_post('ipaddress'));
$userdm->set('referrerid', qpc_post('referrername'));
$userdm->set('timezoneoffset', qpc_post('timezoneoffset'));
$userdm->set_bitfield('options', 'adminemail', intval(qpc_post('adminemail')));
$userdm->set_bitfield('options', 'showemail', intval(qpc_post('showemail')));

$dst_setting = intval(qpc_post('dst'));
switch ($dst_setting)
{
case 0:
case 1:
$userdm->set_bitfield('options', 'dstonoff', $dst_setting);
break;
case 2:
$userdm->set_bitfield('options', 'dstauto', 1);
break;
}

#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";
}
?>
-------------------------------------------------------------------


STEP II



You can have the following code on server running PHP WHEREVER YOU WANT. it does not need to be on the same domain as long as you have the curl compiled


in that script (again call it whatever you want it does not matter)

you call the url of your web server and path to go to the page GREAT_STUFF_DUDE.php

you can of course include it in the login code of your CMS to create profiles in both systems in one step.


-------------------------------------------------------------------

<?php

$url="http://www.mysite.com/vbulletin3000/GREAT_STUFF_DUDE.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "username=keith_mayass&email=keith_mayass@no_worrys.com&password=up_yours&usergroupid=2&");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
$content = curl_exec ($ch); # This returns HTML
curl_close ($ch);

?>
---------------------------------------------------------

you can of course pass as may variables as you want if you have them available in your CMS to complete the profile.

like

parentemail
showbirthday
homepage
icq
aim
yahoo
msn
skype
usertitle
customtitle
birthday



__-----__________------___
Ni vu ni connu, jt' embrouille

This code is work properly
then i need to activate this user when his account on my site activated

--------------- Added 1197356952 at 1197356952 ---------------

Would this approach still work in 3.6.8?

it works properly i'm using 3.6.8

TheNewWebGuy
18 Dec 2007, 14:53
I hope this helps some people.
-Alex

I've been trying to get your code working, but I keep getting the error



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



And that's from just having


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



I can't see anything that would be amiss so any help would be welcomed

Thanks

--------------- Added 1197991803 at 1197991803 ---------------




Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




I was able to fix this by doing te following


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Stiil though, I'm not sure why I can see $vbulliten outside of the class yet not inside it

dionsis
10 Jan 2008, 18:43
Ok can anyone including the developers out there suggest a method for solving

PHP Fatal error: Call to a member function query_first_slave() on a non-object in /path/to/my/forum/includes/functions.php on line 1194

from doing a bit of research it seems this error comes up mostly when a file X.php included file Y.PHP and Y.PHP would include the code for adding a user and in turn would include the globals.php, class_dm.php and class_dm_user.php

so it seems nested including is a problem for objects further down the line

has anyone got any idea's of how we can solve this issue as i'd like to make use of the datamanager for inserting users rather than the silly method of SQL inserting which isnt the best method going

Opserty
11 Jan 2008, 15:35
Ok can anyone including the developers out there suggest a method for solving

PHP Fatal error: Call to a member function query_first_slave() on a non-object in /path/to/my/forum/includes/functions.php on line 1194

from doing a bit of research it seems this error comes up mostly when a file X.php included file Y.PHP and Y.PHP would include the code for adding a user and in turn would include the globals.php, class_dm.php and class_dm_user.php


Make sure you include global.php (not globals.php) at the very top of your script, the advised method of doing so is with a chdir().


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Try it out.

dionsis
14 Jan 2008, 02:32
i do include global.php

$cwd = getcwd();
chdir('/home/content/d/i/o/dionsis/html/acuffe/test/forum');
require_once('./global.php');
require_once('./includes/class_dm.php');
require_once('./includes/class_dm_user.php');
chdir($cwd);

$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";
return(false);
}
}
else
{
# If everything is OK
$newuserid = $userdm->save();
print "vbuserid:$newuserid\n";
return(true);
}

dionsis
24 Jan 2008, 14:08
Nobody have any idea's on this? i might post this to the vbulletin programming forum and see if anyone see's it better there

scoopr
01 Feb 2008, 14:26
I was pleased to find amatulic's class.forumops.php as that was exactly what I needed, excellent work!

However, I found the user login part of it acting a bit weird.



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




If you look at the function, it does not use the $vbuser['password'] value at any point! This means, if you use this login function in some page, it logs in successfully any user no matter what she supplied as her password!

You might need forcing successful login when you have custom user database you check against yourself and want to ignore vbulletin user database and still be logged in to vbulletin, but in my eyes, the class implied it actually checked against the vb user database (the comments have an example where it supplied the password).

I replaced the login method as follows, now it returns true when the login is successfully, false otherwise. I'm not totally sure if the md5 passwords are totally correct here, but seem to work in my quick test.



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




Feel free to comment if I had misunderstood something, but I felt it would be important bring this issue up, if someone else uses this class as a login method assuming the same thing as I did.

Oh, and this skips the userdata conversion part, as I felt it was a bit pointless in this context.

Iron Guard
11 Feb 2008, 10:32
I have found the datamanager_user class (class_dm_user.php) in the includes folder of the vbulletin directory on my server.

Now could anybody please suggest me what files do I need to include in my script before I could instantiate the datamanager object and run the add process successfully?

1. What files do I need to include in my script to create a database connection?
2. Any function files that I need to include to run the process successfully?
3. Any other class file that is related with this class_dm_user.php file and required to be included as well?

Thanks.

WebConnection
14 Feb 2008, 08:10
Is there any tables may be affected when adding a new user except for the 'user' table? If so, what are they?

matzelkoenig
25 Mar 2008, 18:55
I am using your functions in my project and it worked very well! But now I want to add also an customavatar picture for new users. How can I do this with your ForumOps Code?

upnorth
01 Apr 2008, 15:04
Can anyone tell me where there might be a complete updated list of what can be set for a new user in vB 3.6.9 Seems the list provided in the initial post (see below) is a little dated.

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

...

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


....

Opserty
02 Apr 2008, 10:14
Can anyone tell me where there might be a complete updated list of what can be set for a new user in vB 3.6.9 Seems the list provided in the initial post (see below) is a little dated.
I don't think there have be many changes, maybe just ask about a specific field either in this thread of one of the other vBulletin.org forums.

upnorth
02 Apr 2008, 16:49
The ones I seem to be running into problems with are the ones below:

$newuser->set_bitfield('options', 'receivepm', '1');
--this dosn't seem to set the "Receive Private Messages" for the user to "Yes"

$newuser->set_bitfield('options', 'emailonpm', '1');
--this dosn't seem to set the "Send Notification Email When a Private Message is Received" for the user to "Yes"

Pop up a Notification Box When a Private Message is Received
--not sure what the option is to set this one?

Opserty
02 Apr 2008, 17:59
Try:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Does that work?

upnorth
02 Apr 2008, 18:19
nope, didn't work

JulienT
13 Apr 2008, 20:13
This was a really good code that helped me integrate VB with my existing website.
Any idea if those functions will still work in 6.7?
I will wait for the final release of course of 6.7, but having this code working is a key factor for me to upgrade or not.

So if someone has tried this code on 6.7, please let us know.

Thanks.

binevi
14 Apr 2008, 00:03
Can anyone explain step by step? How and where do we suppose to put these codes ;(

upnorth
24 Apr 2008, 19:28
Still running into problems with these as well as showimages

Anyone? Anyone lol :D

The ones I seem to be running into problems with are the ones below:

$newuser->set_bitfield('options', 'receivepm', '1');
--this dosn't seem to set the "Receive Private Messages" for the user to "Yes"

$newuser->set_bitfield('options', 'emailonpm', '1');
--this dosn't seem to set the "Send Notification Email When a Private Message is Received" for the user to "Yes"

Pop up a Notification Box When a Private Message is Received
--not sure what the option is to set this one?

coffeesgr
25 May 2008, 12:20
Anyone know how to fix error:
Fatal error: Registry object is not an object in [path]/includes/class_dm.php on line 177
#0 vb_error_handler(256, Registry object is not an object, /home/gymchat/public_html/messageboards/includes/class_dm.php, 177, Array ([this] => vB_DataManager_User Object ([validfields]


i use a modified version of the code they gave a couple posts back which works great for me.


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



I would have taken more time to tinker with it, and possibilly put it in a function, but as there is only 1 place in my scripting but that works fine for me.
Im running it on vBulletin 3.6.2

grenma
28 May 2008, 02:02
This is the only auto-login/auto-register/integration information in all of support as far as I can tell. It is 3 years old and, while giving thanks to the author and noting that it is better than nothing, it hardly classifies as much more than a code snippet. I've seen dozens of posts on integration here that could be addressed by expanding and updating this information- surely it is not too much to ask?

--------------- Added 1211943709 at 1211943709 ---------------

Thank You!

--------------- Added 1211943812 at 1211943812 ---------------

Anyone know how to fix error:
This did the trick for me

--------------- Added 1211943912 at 1211943912 ---------------

changing to the vb install directory is the key

coffeesgr
28 May 2008, 05:25
What fixed the error for you?

This does change to the vb directory:
chdir('/home/site/public_html/forum');

wassimeh
10 Jun 2008, 16:35
Thanks coffeesgr your code works #1 when executed directly; unfortunately it won't work when i use it inside a $_POST action.. please help.. what am I doing wrong ? here's my code below

<?php
//Ajouter l'utilisateur dans la database du forum
if(isset($_POST['btn_update'])){
/*
$username=$_POST['username'];
$email=$_POST['email'];
$password=$_POST['password'];
$usergroupid=$_POST['usergroupid'];
$timezoneoffset="-5";
*/
$username="username";
$email="email@address.com";
$password="password";
$usergroupid="2";
$timezoneoffset="-5";

define('THIS_SCRIPT', 'remote_register.php');
chdir('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();
}
chdir('..');
}


?>
<form name='f_updaccess' method='post' action='test.php'>
username : <input type='textarea' name='username' value='user2'>
email : <input type='textarea' name='email' value='email@haha.ca'>
pass : <input type='textarea' name='password' value='password'>
usergroup : <input type='textarea' name='usergroupid' value='9'>
<input type='submit' name='btn_update'>
</form>

nautiboy
14 Jun 2008, 03:15
I know this question was asked earlier, but it was never answered.

Is there any way to handle the case where the password you have is an md5 hash? I don't like sending passwords in the clear, so my login pages do the md5 hash before sending up to the server, so I don't have access to the actual password.

Any ideas?

--------------- Added 1213414760 at 1213414760 ---------------

OK, I've managed to answer my own question. It turns out that you can use md5's also. If you pass in a plain-text, it will md5 it. But if you pass in an md5, it will use it as-is (basically it just checks to see if the password is 32 characters long - if it is, it assumes it's an md5).

So it "just works". Cool! :up:

scoutz
26 Jun 2008, 09:23
I don't know if this has been covered yet but if you would like to show the username and userid in your activation mail you just have to set $username and $userid to the appropriate values.

ram94401
08 Jul 2008, 05:59
Hi. I'd like to be able to send the registration email after the user registers. How do I do this. Thanks in advance.

-- edit --

I answered this one myself

$activateid = build_user_activation_id($newuserid, 2, 0);
eval(fetch_email_phrases('activateaccount'));
vbmail($email, $subject, $message, true);


Thanks. But, when you do $userdm->save, won't the user is automatically activated? I assume that you used the code in http://www.vbulletin.org/forum/showpost.php?p=864803&postcount=31;

--------------- Added 1215493772 at 1215493772 ---------------

All right. This entire integration thing works partially for me. After getting frustrated, I wrote the program to get the user data from the form and update the Vbulletin tables directly.

Here is the logical flow:

1. I updated user and useractivation tables with the user information. I set the usergroupid as "3" (users waiting for email activation group) in user table and added the row for the new user in useractivation table. This row will be deleted when the user activates the account.

2. I sent the activation email to the user. This is a nice thing, because I can customize the email format. If a user registers in the main site and the forum sends the activation email, it looks kind of weird. Because some users of our CMS site don't even know what is a forum.

3. User clicks the link in the activation email. Program checks the activation id in the useractivation table. If everything is ok, the usergroupid is changed from 3 to 2 in usertable. Activation record in useractivation table is deleted, because it's no longer needed.

Ok. All works well. The user can do anything he wants just as he would normally do when he registers using forums/register.php.

But..(you know it's coming!) there is a headache for the admin. In the admin control panel, username, email, IP, and all those fields are EMPTY for this user. Options like receive admin email, PM options, etc., are all set ok. Only the username, email, IP fields are empty.

Do I need to update another table? Doesn't admin control panel use the user table to display the user profile?

ArbuZz
10 Jul 2008, 20:38
Personally I got very odd:"Existing data passed is not an array" while using amatulic's class and when doing:


$userdata['username'] = $_POST['username'];
$userdata['password'] = $_POST['password'];
$userdata['email'] = $_POST['email'];
$forum->register_newuser($userdata));


What maybe the problem? Anyone?

--------------- Added 1215718968 at 1215718968 ---------------


Called set_existing in ..class.forumops.php on line 296
Called login in ..class.forumops.php on line 153


I guess this has something with vBulletin's way to manage database connections :(

--------------- Added 1215719381 at 1215719381 ---------------

This doesn't help:

$cwd = getcwd();
chdir('.../forum');
require_once('global.php');
chdir($cwd);

--------------- Added 1215760256 at 1215760256 ---------------

ok. for some unknown reason in the userdata_convert function exist the following line:
$vbuser = array( 'username' => $userdata['userid'] );

:confused: but why?! I guess it has to be:

$vbuser = array( 'username' => $userdata['username'] );

I've moved amatulic's class in the different place, stored variables in $_SESSION and called header redirect to it. So that now it has totally separated namespace. However I'm not sure if this is secure thing to do.

As I've figured out, there is some problem with login part, cause as soon as I turned it off, I was able to register user in vBulletin. At least it has showed up in the database.

--------------- Added 1215760677 at 1215760677 ---------------

It is "function fetch_userinfo_from_username" that does the trouble. It is not able to retrieve the information from database with its:


...
global $vbulletin;
$useridq = $vbulletin->db->query_first_slave("SELECT userid FROM " . TABLE_PREFIX . "user WHERE username='{$username}'");
...


Any ideas how to correct this?

--------------- Added 1215769463 at 1215769463 ---------------

ok. for some reason $login variable is set to true in register_newuser so that it tries to login user by default as soon as he/she is registered. However it seems that user is not inserted in database yet, when the function tries to login him/her. I don't know why, but that's what happens. So I've turned $login to false, like this:

function register_newuser(&$userdata, $login = false)

Also I rewrote db connection, but I think It worked without it. Now everything works. Thank you amatulic. I've lost two days figuring out the faults, but thanks god it works and that's the best news :) Here is my working version if anyone's interested:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



One additional note. I don't use update and delete functions of this class, so I didn't test them. Have that in mind when using.

Jonaid
13 Jul 2008, 02:22
Is there any chance that this'll work, cross site? I'd added a forum on a different server to my main site and I wanted to sync the signups so when someone signs up on my main site it signs them up on the forum.

Any advice??

Regards,

Jonaid

ArbuZz
14 Jul 2008, 11:55
You can use cURL php extension, however I do not know whether it is active by default. With cURL you can call any remote php script and pass parameters to it through the ordinary POST, just like you do it from HTML form.

Peter Bowen
20 Jul 2008, 19:11
Hi,

I'm using amatulic's code in an attempt to create a new user but I keep on getting this error even when using the example test code for making a new user. Any ideas?

Fatal error: Existing data passed is not an array
Called set_existing in /var/www/vhosts/carrington-club-international.co.uk/httpdocs/include/class.forumops.php on line 296
Called login in /var/www/vhosts/carrington-club-international.co.uk/httpdocs/include/class.forumops.php on line 153
Called register_newuser in /var/www/vhosts/carrington-club-international.co.uk/httpdocs/testforumreg.php on line 14
in [path]/includes/class_dm.php on line 235

Thanks

Pete

Selter
18 Sep 2008, 13:50
Hi threre,

I've got some trouble running the PHP code from the first post. To be honest - I'm not so familiar with PHP :(

It would be great if anybody could have a look into this ...
(I already posted this issue in the german board http://www.vbulletin-germany.com/forum/showthread.php?t=38534 and was advised to ask the author of the code ;) )

Below you'll find the (entire) code which I use in a PHP file (called createuser.php).

I started the code by entering http://www.xyz.de/_forum/createuser.php in the URL-field of my browser.




Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




Unfortunately I got this error message:



Fatal error: vb_error_handler() [function.require]: Failed opening required 'DIR/includes/functions_log_error.php' (include_path='.:/usr/lib/php') in /xxxxxxx/htdocs/_forum/includes/class_core.php on line 3247




Where is the bug???

Thanks
Selter

Andreas
13 Oct 2008, 08:52
Where is the bug???


init.php


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



=> Set CWD properly, eg. full path

mariusvr
28 Oct 2008, 12:38
--------------- Added 11 Jul 2008 at 16:17 ---------------

It is "function fetch_userinfo_from_username" that does the trouble. It is not able to retrieve the information from database with its:

...
global $vbulletin;
$useridq = $vbulletin->db->query_first_slave("SELECT userid FROM " . TABLE_PREFIX . "user WHERE username='{$username}'");
...

Any ideas how to correct this?

I am having the same error coming up when using the following code. The db object seems to empty when updating the user stats. The strange thing is that the user was created succesfully, before vbulletin crashes with this error:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



I am using the following code:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




This is the final hurdle before releasing a Beta version of JFusion, a revolutionary Joomla universal bridge. Any help would be greatly appreciated.

Thanks, Marius

harty83
30 Oct 2008, 16:52
This is the final hurdle before releasing a Beta version of JFusion, a revolutionary Joomla universal bridge. Any help would be greatly appreciated.

Thanks, Marius

Very unlikely the problem, but you are setting the password twice?


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

thewitt
13 Nov 2008, 03:47
This "Call to a member function" problem occurs when you try to use the Data Manager from within another program.

I have a stand alone php script that works great to set the usergroups using the Data Manager, however when I try to integrate it into my CMS, I get these errors.

I don't know if there is a workaround or not - short of removing the vB includes from the CMS application - but I suspect there is.

It's simply beyond my understanding.

I hat to go with the CURL and remote approach, but I might be forced into it if no one has any other ideas...

-t

mariusvr
01 Dec 2008, 00:13
The problem was that the scope of the global variable is not available to all vbulletin code when called from a more complex script (standalone php file seems to work fine). Our newest addition to the JFusion programmers team has found a solution on how to make it work even from inside another program:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



This resets the global objects in the main script and allows it to be available for the next set of calls to the vb datamanager.

Thanks, Marius

harty83
01 Dec 2008, 00:37
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Just as a FYI, the first line (global $vbulletin) is not necessary. That was overlooked on my part. The full code that got it working is



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Thanks!
Alan

mariusvr
01 Dec 2008, 00:43
No thank you Alan. Great piece of troubleshooting on the issue and you have raised the level of functionality for the vbulletin JFusion plugin by a lot! Its a pleasure to have you involved with JFusion.

Thanks, Marius

jdelator
18 Dec 2008, 21:13
Has this tutorial changed muched for 3.7 since it was original written for 3.5?

Sagi22
29 Dec 2008, 16:44
It seems for me that after including vBulletin's classes that the connection link to the DB is still open, and I can't access my previous DB link.
The problem is that my forum tables are in different datebase.
How I can disconnect from VB link?

Thanks.

apollothethird
20 Jan 2009, 05:13
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.

Andreas, great code!

I have a userfield included in my registration process for Full Name. You can find it in the User Manager under the User Profile Fields section called “Full Name”. Its writing “field5” in the mysql database file.

Can you tell me how to include this in the new users’ creation?

Thanks in advance for any suggestions or comments.

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames

positiverep
23 Jan 2009, 19:07
Has this tutorial changed muched for 3.7 since it was original written for 3.5?

I'm running 3.7 and had no problem installing the script.:D

smooth-c
29 Jan 2009, 11:52
I'm using the integration plugin between Interspire's Email Markerter and i'm now, out of the blue experiencing these problems.

This seems to be working flawlessly except lately i've noticed that it's missed out a few members and not added them to my mailing list.

Any ideas why this would happen? Here's my plugin code;



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

Any help would be greatly appreciated!

tomypro
11 Apr 2009, 00:42
Hi,

Im using ArbuZz's code base and its working create; i am using it as well as a SSO bridge between my app and the integrated vbulletin board.

Once thing i would like to achieve is that as soon as I trigger the login call for a user through my busines logic not only the session cookie is set but that that partiular users appears as online within vbulletin as well.

Is this something that can be achieved through the Data API as well?

//Thomas

nessur
04 May 2009, 22:50
Thank you, and thank you! This fixed my problem.

Just as a FYI, the first line (global $vbulletin) is not necessary. That was overlooked on my part. The full code that got it working is



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Thanks!
Alan

galt
12 May 2009, 15:33
After hours of hacking at this, I am once again stuck. I have included this code in my CMS.



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




and lower down


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



When the second block of code executes, I get the error:

Database object is not an object in [path]/includes/class_dm.php on line 172

I am stumped. I tried adding the global hack referenced a few posts back, and it did nothing for me. I am spending more time trying to get VB rgistration integrated that I am writing my entire CMS!!! ARRRGGGHHH !!!!! I would gladly pay someone to do this for me if I could find them.
**********************************
Nevermind. I just wrote my own object. WAY faster and easier.

php-resource.de
13 May 2009, 10:54
After hours of hacking at this, I am once again stuck. I have included this code in my CMS.



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




and lower down


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



When the second block of code executes, I get the error:

Database object is not an object in [path]/includes/class_dm.php on line 172

I am stumped. I tried adding the global hack referenced a few posts back, and it did nothing for me. I am spending more time trying to get VB rgistration integrated that I am writing my entire CMS!!! ARRRGGGHHH !!!!! I would gladly pay someone to do this for me if I could find them.
**********************************
Nevermind. I just wrote my own object. WAY faster and easier.

I guess you are using the global $db within your CMS.
Try the following workaround:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

galt
13 May 2009, 11:43
Thanks. I had already tried that, then removed it. That was my reference to "the global hack referenced a few posts back". It did not help. At this point I am creating a new user and maintaining critical fields managed with some SQL directly into the vB database. As soon as I figure out cookies and login, I am good to go. That is, until vB changes the user scheme, at which time i will have an ongoing maintenance nightmare. OTOH it took me 2-3 hours to figure out and write the custom code from scratch, and I spent many more hours than that (and got more frustrated) trying to research and utilize the VB object library.

Added -----

After more review, I see that you added lines relating to $backupdb. That may have done the trick, but dealing with vB and its programming philosophy is just a nightmare, and I am too close to done to go backwards again. Thanks for your effort though.

andha513
05 Aug 2009, 23:05
I am porting all my users from a social networking site (Drupal CMS) to our new vBulletin forum, but having a small issue.

Since all Drupal passwords are already MD5'ed, I am simply creating vBulletin users manually by connecting to the vBulletin database and inserting the appropriate data into the user-table, the userfield-table and the usertextfield-table. (Since this is what I gather from the vBulletin registration script)
The users are created fine and working well, except that all users created with my script get the "Guest" title in their forum posts. And I just can't figure out why.
There are no users in the unregistered/guest usergroup (where people are assigned the "Guest" title), so that's not it.
We have no "Guest" user title in the User Title Manager, so that's not it either.

I'm assuming I'm missing to add some data to some table for each user. Would someone here be able to offer some help?

Thanks in advance.

ringleader
07 Sep 2009, 16:22
We have no "Guest" user title in the User Title Manager, so that's not it either.

I'm assuming I'm missing to add some data to some table for each user. Would someone here be able to offer some help?


I assume you fixed your problem by now.

If not, you have to set the usergroup id for each member:
$newuser->set('usergroupid', 2);

andha513
07 Sep 2009, 16:45
I assume you fixed your problem by now.

If not, you have to set the usergroup id for each member:
$newuser->set('usergroupid', 2);

Thanks, but I do set the usergroup id for each member (to 2).
Problem not really solved, but vBulletin's own "fix broken user profiles" feature does correct the user profiles, and I'm ok with this for now.

ringleader
07 Sep 2009, 17:01
usergroupid=2 is normally the default setting for the 'registered users' group.

Go to http://www.YourForumAddressHere.com/admincp/usergroup.php?do=modify and use whichever number for the usergroupid that you want to set for each member you're importing.

The usergroupid sets the permissions that you want the user to have on the forums.
Is that clearer for you?

andha513
07 Sep 2009, 17:39
I appreciate the effort, but I am aware of all this. Unless there is another database table related to the usergroups, the usergroups do not seem to be the problem here.


usergroupid=2 is normally the default setting for the 'registered users' group.

Go to http://www.YourForumAddressHere.com/admincp/usergroup.php?do=modify and use whichever number for the usergroupid that you want to set for each member you're importing.

The usergroupid sets the permissions that you want the user to have on the forums.
Is that clearer for you?

mikesharp
14 Sep 2009, 13:15
Is there an update on a working version of this for 3.8.x ???

thanks all

Mike

ragtek
14 Sep 2009, 15:16
Is there an update on a working version of this for 3.8.x ???

thanks all

Mike
No, the code is still working

webtechuser
24 Sep 2009, 15:30
I cant login from the site page using the user wich i have created according the way described above...can somebody plz help me :(

damianzaremba4
27 Sep 2009, 15:56
I get the error

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

Every time I try to run the code:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

Any one got an idea why?

Thanks.

Andreas
30 Sep 2009, 18:25
Any one got an idea why?

Yep - Variable Scope.

Booting vBulletin from non-global scope is a bit tricky.

Crimm
11 Nov 2009, 20:37
I guess you are using the global $db within your CMS.
Try the following workaround:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------





I just wanted to say that I was implementing this article with Wordpress and kept getting errors about functions_databuild.php on line 1685. So I added "global $vbulletin" and started having the issue of class_dm.php on line 177 about Registry Object. The above code worked for me.

So here's my function (A combination of those in this article for wordpress)



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



and I called it on wp-login.php in the register_new_user function. I added it right after the User Password Generation so I could pass it to vB.



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



That should help some people if you come across this :P

yappa.be
27 Nov 2009, 08:51
Hello,


A few weeks ago, we launched a website with a custom registration in stead of register.php to add new users. With the help of this forum, we succeeded without any problems.

Since last monday, the register was down. The php-code did not change so we have no clue what so ever what could be the problem.

Error code:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------





Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



After doing some searching, we found that the error is generated in the function build_options in includes/adminfunctions.php. This function is called in includes/class_core.php in the function check_options.

Does anybody have an idea what could be the problem. It seems that because of some changes in the settings (or something like that), we lost our database-object but didn't change anything to the code itself.

Crimm
27 Nov 2009, 21:56
I just happen to pass by here looking for something else and I saw your response.

Did you add a profile field, maybe?

Just a thought. If you get it figured out, please post the solution :)

bianca_roma
01 Dec 2009, 12:09
I am porting all my users from a social networking site (Drupal CMS) to our new vBulletin forum, but having a small issue.

Since all Drupal passwords are already MD5'ed, I am simply creating vBulletin users manually by connecting to the vBulletin database and inserting the appropriate data into the user-table, the userfield-table and the usertextfield-table. (Since this is what I gather from the vBulletin registration script)
The users are created fine and working well, except that all users created with my script get the "Guest" title in their forum posts. And I just can't figure out why.
There are no users in the unregistered/guest usergroup (where people are assigned the "Guest" title), so that's not it.
We have no "Guest" user title in the User Title Manager, so that's not it either.

I'm assuming I'm missing to add some data to some table for each user. Would someone here be able to offer some help?

Thanks in advance.

I have the same problem...Did you manage to resolve this issue? i'm desperate...

Iron Star
06 Jan 2010, 17:27
Unfortunately, I obtain this:

Fatal error: Call to a member function do_db_fetch() on a non-object in vb_forum/includes/init.php on line 308

An idea?


I just wanted to say that I was implementing this article with Wordpress and kept getting errors about functions_databuild.php on line 1685. So I added "global $vbulletin" and started having the issue of class_dm.php on line 177 about Registry Object. The above code worked for me.

So here's my function (A combination of those in this article for wordpress)



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



and I called it on wp-login.php in the register_new_user function. I added it right after the User Password Generation so I could pass it to vB.



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



That should help some people if you come across this :P

F5-MVH
07 Jan 2010, 18:49
Using the class ForumOps (which by the way is brilliant)...... I am trying to figure out how to pass a delimited txt file of user information to it. Any help would be appreciated.

To elaborate - We have a corporate text file with the following
'user name','email address'

I need to generate new VBulletin accounts for all them.

Cheers!
Dave

lanzeym
03 Feb 2010, 17:08
Hi,

I am now able to programmatically add user by modifying script above but I have a problem when I tried to insert user from our existing database that has more than 25 character. I’m getting an error “Username cannot be longer than 25 characters”. Can you guide me on how can I disable the maximum characters allowed for username?

I have basic knowledge in php and I look through the following included files but I can't see the function for validation the maximum length.

require_once('./global.php');
require_once('./includes/class_dm.php');
require_once('./includes/class_dm_user.php');

Anybody have done this before?

Thanks!

bigtime
03 Feb 2010, 17:50
lanzeym, sounds like you may need to make your existing database field for username larger than 25 characters.

lanzeym
03 Feb 2010, 18:09
hi bigtime!

The save() methods uses vBulletin "user" table that has varchar(100) length, so there's no need for changing field lenght. There should be a hard coded "maxlength" that I don't know where it is.

bigtime
03 Feb 2010, 18:37
Oops, I misunderstood. I thought you were inserting users into your existing database...

lanzeym
04 Feb 2010, 18:12
here's how to remove the validation.

AdminCP > vBulletin Options > User Registration Options > Maximum Username Length

Tibald
29 May 2010, 15:30
Anybody can help with code example for manual users registration and login for vb 4 ?

ilbianconiglio
13 Jul 2010, 14:59
I'm trying to add a new user with VB 4.0.

I'm using the latest snippet of code but when I do $newuser->save(); it saves the record to the db but return to a Database error page ( of VB ).

What can I do?

--------------- Added 1279029801 at 1279029801 ---------------

Ok maybe I solved.

For VB 4 you need to add this:

$newuser->pre_save();

before save() or checking errors :)

calwebsnc
20 Jul 2010, 10:09
Hi,
I am trying to do something similar.
I wrote a class inside a file in the main directory of my forum.
This is the code:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



I receive this error:
Fatal error: Call to a member function do_db_fetch() on a non-object in /var/www/cyberludus.com/system/forum/includes/init.php on line 308

Where I do wrong?
Thank you

epolitica
23 Nov 2010, 15:32
The code seems to be working, but when in debug mode a lot of notices show up. I`d rather they shouldn`t:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




Then I got a question, is it possibile to add an user in an inactive state, and only after a third party email validation, enable him/her? I couldn`t find any column in the vb_user table that indicates this active/inactive state, any help?

adbox
25 Jan 2011, 16:59
Looking for an updated version of this script for 4.1.1

Am getting this error:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



--------------- Added 1295975525 at 1295975525 ---------------

This works for me.

add_user.php (custom API)



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

Andreas
26 Jan 2011, 19:21
Looking for an updated version of this script for 4.1.1

Am getting this error:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



This is caused by a Bug (http://tracker.vbulletin.com/browse/VBIV-10778) that should be fixed in one of the next releases.

In the meantime you can simply add


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------


to your code.

nack
05 Aug 2011, 16:19
I used this code and everything was working fine. Users got added, but when they tried to login, they got this message:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



I looked in the banned list. They are not in there. What could have been wrong?

ingwa
07 Sep 2011, 21:04
Nack, make sure the user group that your user is being created under is being defined. If you aren't in the right group then they show as being banned. Hope this helps.

dog199200
03 Dec 2011, 13:03
I keep getting a fatal error:Fatal error:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



I slightly modified the code above:

Main Code


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



I could really use some help please. :P

adbox
06 Dec 2011, 16:50
Maybe this resource is related?

http://www.vbulletin.org/forum/showthread.php?t=267099

dog199200
06 Dec 2011, 19:19
Maybe this resource is related?

http://www.vbulletin.org/forum/showthread.php?t=267099

They seem to be, but it doesn't exactly answer the question. I noticed i only get the error because of my header which i need:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



I have that added to the top of every single page because i've build my own api system for my main website around it.

adbox
06 Dec 2011, 19:28
What if you change your header to this:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



I'm not certain the change directory commands are necessary.

dog199200
06 Dec 2011, 19:34
Doesn't work. I had to change the directory before because I had to call a lot of the internal features within vB. I'm pulling user information and login checks of all types all over the site. If i just include the global instead of redefining the directory I get this error:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Edit: Basically without the header being as how i had it, my whole site would break.