MyBB Community Forums

Full Version: To get the username of the logged in user
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
What expression should I use so as to get username of the logged in user?

I tried
<?php echo $mybb->user['username']; ?>
But it did not work. Sad
{$mybb->user['username']}
Where are you trying to use it?
(2012-08-08, 02:44 PM)Vernier Wrote: [ -> ]Where are you trying to use it?

I am trying to use it in my mycode
(2012-08-08, 02:44 PM)Fábio Maia Wrote: [ -> ]
{$mybb->user['username']}

Fábio is correct.
So would it be
username = {$mybb->user['username']};

If so then it is not working.

More details:
I am running a online gaming site and am using mycode to embed game from mochi(flash games provider) and there is an option to add highscores so I am using this code:
<embed src="$3" menu="false" quality="high" width="$1" height="$2" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
<div id="leaderboard_bridge"></div>
<script src="http://xs.mochiads.com/static/pub/swf/leaderboard.js" type="text/javascript"></script>
<script type="text/javascript">
// Mochi Bridge
var options = {partnerID: "dcb8a6a56f111489", id: "leaderboard_bridge"};
options.userID = "<?php echo $mybb->user['uid']; ?>";
options.username = {$mybb->user['username']};
//options.profileURL = "{$mybb->settings['bburl']}/member.php?action=profile&uid={$mybb->user['uid']}";
//options.logoURL = "<?php echo $setting['siteurl']; ?>de16X16.jpg";
//options.siteURL = "<?php echo $setting['siteurl']; ?>";
//options.siteName = "<?php echo $setting['sitename']; ?>";
options.globalScores = "false";
options.denyScores = "Login to '. $setting['sitename']. ' to submit scores!"';
options.denyFriends = "true";
Mochi.addLeaderboardIntegration(options);
</script>

When one is viewing the game I need the varibales to be replaced by the catual valur. For example in username field the value should be the username of the logged in user.

Help please! Sad