MyBB Community Forums

Full Version: Need help with Mybb User Code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi! I am working on a new website for my clan and its using mybb and i can't seem to be able to get all of the pages to show the usernames i put this code on the pages "{$mybb->user['username']}" on my code it's only showing the my username on one page. i put the home page code on Templates ---> Newest Site Template -----> It's Under Index Page Templates -----> Index <---- thats where i put my home page code at.


This is the page it works on:
This is the page where i posted the code into
Templates ---> Newest Site Template -----> It's Under Index Page Templates -----> Index <---- thats where i put my home page code at


[Image: onlypageitworks.png]







This is the What it shows on the rest of the pages:
[Image: yololol.png]


[Image: aboutus.png]










Please Help me! I would like to know how to get all of my pages to show the username. Here is a Test account to see for your self on what i'm talking about.

test account info
username: test
password: test1234

Login at:
http://therapiidzclan.tk/login.php
in general, custom pages include global.php file. after that you can add $mybb as global variable so that {$mybb->user['username']} works
require_once ('./global.php);
global $mybb;
(2014-01-14, 03:28 AM).m. Wrote: [ -> ]in general, custom pages include global.php file. after that you can add $mybb as global variable so that {$mybb->user['username']} works
require_once ('./global.php);
global $mybb;


How do i access the Global.php?

(2014-01-14, 03:28 AM).m. Wrote: [ -> ]in general, custom pages include global.php file. after that you can add $mybb as global variable so that {$mybb->user['username']} works
require_once ('./global.php);
global $mybb;

Also where do i add the Code to and at?
^ add in your custom pages files. eg. about.php , contact.php ..
(2014-01-14, 03:44 AM).m. Wrote: [ -> ]^ add in your custom pages files. eg. about.php , contact.php ..

Wait what? Lol you lost me.
oh! I have overlooked !!
you have {$mybb->user['username']} in index template - remove that and add it to header_welcomeblock_member template
(2014-01-14, 03:53 AM).m. Wrote: [ -> ]oh! I have overlooked !!
you have {$mybb->user['username']} in index template - remove that and add it to header_welcomeblock_member template

It still doesn't work.... i built the username into the page like this...

<!-- BEGIN USER LOGIN DROPDOWN -->
<li class="dropdown user">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true">
<img alt="" src="http://therapiidzclan.tk/default_image.jpg"/>
<span class="username"> {$mybb->user['username']} </span>
<i class="icon-angle-down"></i>
</a>
<ul class="dropdown-menu">
<li><a href="profile.html"><i class="icon-user"></i> My Profile</a>
</li>
<li><a href="page_calendar.html"><i class="icon-calendar"></i> My Calendar</a>
</li>
<li><a href="inbox.html"><i class="icon-envelope"></i> My Inbox <span class="badge badge-danger">0</span></a>
</li>
<li><a href="#"><i class="icon-tasks"></i> My Tasks <span class="badge badge-success">0</span></a>
</li>
<li class="divider"></li>
<li><a href="javascript:;" id="trigger_fullscreen"><i class="icon-move"></i> Full Screen</a>
</li>
<li><a href="lock.html"><i class="icon-lock"></i> Lock Screen</a>
</li>
<li><a href="http://therapiidzclan.tk/new/member.php?action=logout&logoutkey=331fcf6121a6611c83352962a960c190"><i class="icon-key"></i> Log Out</a>
</li>
</ul>
</li>
<!-- END USER LOGIN DROPDOWN -->
What if you insert another $mybb, such as {$mybb->settings['bburl']}?
(2014-01-14, 12:02 PM)Destroy666 Wrote: [ -> ]What if you insert another $mybb, such as {$mybb->settings['bburl']}?

where exactly would i put that in the code?

(2014-01-14, 12:02 PM)Destroy666 Wrote: [ -> ]What if you insert another $mybb, such as {$mybb->settings['bburl']}?

Where Would i insert that code into? I will post the Files for you guys to look at. It's Only the Code for my about and contact page.

Contact.php Page
[attachment=30850]


About.php Page
[attachment=30851]
You can't just add {$mybb->user['username']} directly to file with HTML...
<span class="username">{$mybb->user['username']}</span>
It's handled as text right now.

You need to display the variable with PHP in your files (I don't recommend it, it looks quite messy) or use MyBB's template system to create the upper bar - that would be the header template.

As for custom pages like Contact Us, I recommend Page Manager (again, to prevent mess):
http://mods.mybb.com/view/page-manager
Pages: 1 2