MyBB Community Forums

Full Version: Username include - What to call?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In relation to me trying to find a way to accomplish this, (posted in support last night)

I'm thinking that the best way to do this is to pull through the logged in members username by including what ever relevant MyBB functions I need to do that. As the store page requires members to be logged in you can't order any products without being so, so I should be able to pull through the username and store it as a variable in my IPN to add to my purchases database.

So in short, my second question on this is, using a non related page /ipn.php what do I need to include to be able to read the MyBB usertable and store logged in username as a variable, as I said I'm looking for the php includes I'll need.

Sorry, but I find it hard to explain via writing and my knowledge of MyBB's inner workings is limited.
Why you need username when you can deal with UID?


define("IN_MYBB", 1);
require_once "./global.php";

if(!$mybb->user['uid']){
error_no_permission();
}
		$insert['field_01'] = "Some Value";
		$insert['order_time'] = time();
		$insert['uid'] = $mybb->user['uid'];

		$db->insert_query("shop_table",$insert);
		
			redirect("some.php","Some Message");


This will insert the UID of the operating user in your Shop's UID column.

Guess you can identify and alter the sample texts mentioned in the code.
(2013-04-15, 11:21 AM)effone Wrote: [ -> ]Why you need username when you can deal with UID?


define("IN_MYBB", 1);
require_once "./global.php";

if(!$mybb->user['uid']){
error_no_permission();
}
		$insert['field_01'] = "Some Value";
		$insert['order_time'] = time();
		$insert['uid'] = $mybb->user['uid'];

		$db->insert_query("shop_table",$insert);
		
			redirect("some.php","Some Message");
}

This will insert the UID of the operating user in your Shop's UID column.

Guess you can identify and alter the sample texts mentioned in the code.

The username is used by another system, My MyBB installation is integrated with another application, this is using the username and password, so I need it to capture the username ideally.
Try using:

$mybb->user['username'];
(2013-04-15, 11:30 AM)effone Wrote: [ -> ]Try using:

$mybb->user['username'];

Thank you very much effone, I'm implement these into my IPN tonight and see how I go.