Making a custom MyBB Variable - How to make your username formatted in welcome block 06-06-2013, 07:45 PM
#1
I've been recently learning PHP and I'm pretty far on with it now. I'm just testing out different functions on MyBB which can make your board more custom/unique.
Today I'm going to show you how to make your username in the 'Welcome Block' formatted to whichever usergroup you are in.
End result of tutorial:
![[Image: b48cad5f9ef9d39fec2043edc4aca55b.png]](http://gyazo.com/b48cad5f9ef9d39fec2043edc4aca55b.png)
Here's how:
Open up FileZila or cPanel. You're going to be editing the "global.php" file so open that file up in your code editor.
Once the global.php file is open, search for this line:
Just underneath it, paste this (I'll explain it afterwards):
The $formatted_user_welcome part of the code is our PHP variable. Whatever it's value is, is written after the "=". The code on the other side of the "=" defines what we want to do, which in this case is to style your username.
Save that global.php file and re-upload it.
Now open up your AdminCP. Go to templates -> your theme -> header -> header_welcomeblock_member
Now paste this MyBB variable anywhere you like:
This will display whichever user is logged in's username.
I hope this was easy for everyone to understand.
Today I'm going to show you how to make your username in the 'Welcome Block' formatted to whichever usergroup you are in.
End result of tutorial:
Spoiler:
![[Image: b48cad5f9ef9d39fec2043edc4aca55b.png]](http://gyazo.com/b48cad5f9ef9d39fec2043edc4aca55b.png)
Here's how:
Open up FileZila or cPanel. You're going to be editing the "global.php" file so open that file up in your code editor.
Once the global.php file is open, search for this line:
Quote:// Format the welcome back message
Just underneath it, paste this (I'll explain it afterwards):
PHP Code:
$formatted_user_welcome = format_name($mybb->user['username'], $mybb->user['usergroup'], $mybb->user['displaygroup']);
The $formatted_user_welcome part of the code is our PHP variable. Whatever it's value is, is written after the "=". The code on the other side of the "=" defines what we want to do, which in this case is to style your username.
Save that global.php file and re-upload it.
Now open up your AdminCP. Go to templates -> your theme -> header -> header_welcomeblock_member
Now paste this MyBB variable anywhere you like:
PHP Code:
{$formatted_user_welcome}
This will display whichever user is logged in's username.
I hope this was easy for everyone to understand.





![[+]](https://sinister.li/images/modern/collapse_collapsed.png)



![[Image: a319ef9581853.560e3236d2b0b.png]](https://mir-s3-cdn-cf.behance.net/project_modules/disp/a319ef9581853.560e3236d2b0b.png)

