Log in

View Full Version : Inserting a new user into multiple tables.


Radon3k
11-25-2004, 02:10 AM
Currently on my site you have to register for the site and then again for the forums. What I would like is to be able to have one registration form that registers you for both the forums and the site. When you fill out the form and submit it, 2 queries are sent; 1 query to the actual website table that handles the user functions there and 1 query to the forum table to register the new user. However looking at the vBulletin code there were several queries made to the database for registering a new user. How does one go about accomplishing something like what I'm trying to do? When the user registers he/she should go into to standard usergroup. To make things a little more complex, I want to includ email activation through my site, not the forums. So when a user registers on the site, they are also registered on the forums and receive an email to activate their account. When the account is activated it updates both tables. Any ideas? Thanks. :)

Zachery
11-25-2004, 02:56 AM
Currently on my site you have to register for the site and then again for the forums. What I would like is to be able to have one registration form that registers you for both the forums and the site. When you fill out the form and submit it, 2 queries are sent; 1 query to the actual website table that handles the user functions there and 1 query to the forum table to register the new user. However looking at the vBulletin code there were several queries made to the database for registering a new user. How does one go about accomplishing something like what I'm trying to do? When the user registers he/she should go into to standard usergroup. To make things a little more complex, I want to includ email activation through my site, not the forums. So when a user registers on the site, they are also registered on the forums and receive an email to activate their account. When the account is activated it updates both tables. Any ideas? Thanks. :)
I would do it though the vB end personaly :)

You are going to want to look at register.php for abit of help

Radon3k
11-25-2004, 03:07 AM
I don't want to do the registering through the vBulletin end. I want vBulletin to have almost nothing to do with my main site which is why I'm doing it this way. The way it is setup now on my site is you have to register both on the site and the forums and I'm fine with that but I'm sure users would like to ease of one registration process. Also, I have looked through register.php and there were several sections that could potentially be involved with the registration process hence why I'm asking here.

Radon3k
11-27-2004, 08:02 AM
I don't want to do the registering through the vBulletin end. I want vBulletin to have almost nothing to do with my main site which is why I'm doing it this way. The way it is setup now on my site is you have to register both on the site and the forums and I'm fine with that but I'm sure users would like to ease of one registration process. Also, I have looked through register.php and there were several sections that could potentially be involved with the registration process hence why I'm asking here.
Anybody have any suggestions?

Zachery
11-27-2004, 06:40 PM
Anybody have any suggestions?
You are going to need to populate at least three rows in 3 tables everytime someone registers, like i said look at the register.php file for help.

Radon3k
11-29-2004, 07:45 PM
You are going to need to populate at least three rows in 3 tables everytime someone registers, like i said look at the register.php file for help.
I have looked in register.php and I don't see where it's inserting the user. It's checking so many conditions on where to put the user and I don't need that. I just want the user, when registered through my site, to go into the users awaiting validation usergroup. Everything else is normal and can be left as is. The password is also another issue I'm having as I don't understand the way vBulletin has encrypted the password (yes, I've looked in the correct functions file). I'm looking for a simple way to insert a user into the vBulletin database as well as mine (they are in separate databases and I can work around that).

Radon3k
11-30-2004, 06:49 PM
I've looked through this file and maybe it's just that I don't understand it but I don't see where exactly this stuff is. I've looked through it and I see where the various actions are being done. I'm not looking for someone to write the code for me but instead point out the necessary code from the vBulletin files I need in order to make this work. I can write the code to integrate what I need as long as I have the right code from vBulletin.

Brad
11-30-2004, 07:02 PM
I've looked through this file and maybe it's just that I don't understand it but I don't see where exactly this stuff is. I've looked through it and I see where the various actions are being done. I'm not looking for someone to write the code for me but instead point out the necessary code from the vBulletin files I need in order to make this work. I can write the code to integrate what I need as long as I have the right code from vBulletin.
Check this area of register.php out.

// ############################### start add member ###############################
if ($_POST['do'] == 'addmember')
{

Radon3k
11-30-2004, 08:01 PM
Check this area of register.php out.

// ############################### start add member ###############################
if ($_POST['do'] == 'addmember')
{

Thanks Brad. Do I need to include any file so that this works properly (aside from the file that holds the functions for the salt passwords)? I'm beginning to think it would be easier just to do the entire registration thing through vBulletin but I'll keep at it.

rake
11-30-2004, 08:07 PM
yeah. doing it through vbulletin would be much easier. check for the query that inserts the info in the user table (look for something like $userid = $DB_site->insert_id(); ) and then switch databases and insert the stuff you need into your site database. don't forget to switch back to the vbulletin database after that.

Radon3k
11-30-2004, 08:22 PM
yeah. doing it through vbulletin would be much easier. check for the query that inserts the info in the user table (look for something like $userid = $DB_site->insert_id(); ) and then switch databases and insert the stuff you need into your site database. don't forget to switch back to the vbulletin database after that.
I understand it would be easier doing it through vBulletin but to be honest I really don't want to. I would think I could just copy and paste the necessary information to my register file and link it to the vBulletin database but I'm curious as to which files I would have to include in order to do that. Any ideas?

Radon3k
12-01-2004, 07:48 PM
I understand it would be easier doing it through vBulletin but to be honest I really don't want to. I would think I could just copy and paste the necessary information to my register file and link it to the vBulletin database but I'm curious as to which files I would have to include in order to do that. Any ideas?
I would think for some of the more experienced hackers this would be very easy. I've tried messing about with this and I'm not having much luck and I would really appreciate some help. Thanks.

psalzmann
07-05-2007, 02:57 AM
Not that it helps, but try this:

1. install vb fresh, locally
2. register in your fresh vb as a new user
3. monitor the tables

Questions:
1. What table(s) was populated?
2. Anything needing done to usergroups?
3. Anything else noticable?

I would start there. You can then do it manually once you know what vb requires as a new user. I do think you'll need to have the password for the vb user manually salted and hashed while adding to the vb user table. The email address for that vb user can be associated with your user table in your other app. That could be the common key here.

This can actually be approached in many ways but if I was to do this right now, I'd spend 10 minutes installing fresh and doing that I've mentioned above just to be safe .. if you are not fully understanding the vb datastorage methods and coding.

Peter

Eikinskjaldi
07-05-2007, 04:08 AM
I haven't done this for user, but basically what you want is the user datamanager

your code will look *something* like this

require_once('includes/functions.php');
$userdm = datamanager_init("User");
$userdm->do_set('username', $username);
$userdm->do_set('email', $email);
//heaps more stuff here
$userdm->save();


have a look at includes/class_dm_user.php, and note that some of the required params are bitfields, and will need to be set with set_bitfield.

Its not trivial.