MyBB Community Forums

Full Version: What line on what page actually inserts the user into the DB?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I want to know what line on what page actually inserts the user into the DB. The reason being for this is because I need to run an aditional query there to insert the user info into another part of my website.

Thanks in advance Smile
Line 1052 of ./inc/datahandlers/user.php:

$this->uid = $db->insert_query("users", $this->user_insert_data);
Thanks so much! Will go take a look at that now and make sure that it works.

Edit: Yep, it works! One other question related to this:

How can I get the UID of the user that is about to be inserted? I want the user id's of the forum to the user id's of my site to be the same for each member. Would I have to run a query and select the last user in the user table, or is there a simpler way?
That's what $this->uid is...
But how do I get the user ID from that? Because $this->uid itself isn't JUST the UID.
I just wrote this, do you think it will work for getting the ID of the new user?

		$lastid = $db->query("SELECT * FROM mybb_users ORDER BY uid DESC LIMIT 0,1");
		while($thelastid = mysql_fetch_assoc($lastid)){
		$oldid = $thelastid['uid'];
		$newid = $oldid + 1;
		}
I placed that code right under $this->uid.
... yes, it is... Undecided The insert function returns the ID of the new row, which is the new UID, and then uses that variable in other places in the code...
(2010-12-29, 08:04 PM)MattRogowski Wrote: [ -> ]... yes, it is... Undecided The insert function returns the ID of the new row, which is the new UID, and then uses that variable in other places in the code...

Ohhh ok... I'm still learning MyBB coding a bit. But just doing something like echo $this->uid won't output the new UID, will it?
Yes, it will, that is the variable for the new UID. Try it for yourself, after the code I posted above, add:

echo $this->uid;exit;

Register a new account, it'll echo the UID of it.
Oh, ok! Thanks so much Big Grin I will use that Smile
sorry to confuse you but...

please realize that $this->uid is only valid inside the user.php datahandler file itself and will be a different variable in the member.php page once the datahandler passes functionality back to the main member.php code.

i do not have the code available right now to look, but if you plan on using the UID in other areas during or after registration, just be aware that $this->uid will not always be valid or accessible
Pages: 1 2