MyBB Community Forums

Full Version: Output $name ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have MyBB installed at ./forums folder.

I have another page named profile.php at root. Below is part of code from profile.php .

<?php
define("IN_MYBB", 1);
require ('forums/global.php');
if($mybb->user['uid'] > 0)
{
    $uid  = $mybb->user['uid'];
    $user = get_user($uid);
    $name = $user['username'];
	echo $name;
}
else {
echo "You are not logged in!"; }
?>

Am I right to say that it will output $name if I had already logged into MyBB Forums? However, it keep telling me "You are not logged in!" .

Those file have not been uploaded to any server online yet. I'm testing it using my Localhost [WAMP Server]
Right after require ('forums/global.php'); type the following and post the results.
echo var_dump(MYBB_ROOT, $mybb->user);
This is my edited code,
define("IN_MYBB", 1);
require ('forums/global.php');
echo var_dump(MYBB_ROOT, $mybb->user);
?>

What to do next? It output:

Quote:string 'C:\wamp\www\Personal\Milkmon\forums/' (length=36)

array (size=6)
'usergroup' => int 1
'username' => string '' (length=0)
'uid' => int 0
'displaygroup' => int 1
'lastvisit' => int 1399011567
'ismoderator' => boolean false

I logged in, the username and uid are always blank and zero.

Thanks for helping. I found another way to do that myself.