MyBB Community Forums

Full Version: Username and profile link in templates
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm trying to make an alternative user panel but i don't want to use "{$lang->welcome_back}", I just want to display the user's username with a link to his profile. I'm not very good with php, is it possible to do something like this without modyfing the lang files?
to display user's username with link to his profile, do this:

In global.php.

Change this:
$lang->welcome_back = $lang->sprintf($lang->welcome_back, $mybb->user['username'], $lastvisit);

To this:

$lang->welcome_back = $lang->sprintf($lang->welcome_back, build_profile_link($mybb->user['username'], $mybb->user['uid']), $lastvisit);
Thank you! I tried changing a little bit the lang file, the global.php and the panel templates and i obtained what i wanted.
How can i insert an image in the php code you posted?
something like:

<img src=\"http://yourimagelink.com\">
(2011-10-11, 05:18 AM)crazy4cs Wrote: [ -> ]something like:

<img src=\"http://yourimagelink.com\">

Just being picky, but that should be:

<img src=\"http://yourimagelink.com\" alt=\"img\" />
alt isn't needed, I don't use it, title can be useful, but I never include alts.
No need for core file edits. Just use this code in welcomeblock template.

<a href="{$mybb->settings['bburl']}/member.php?action=profile&uid={$mybb->user['uid']}">{$mybb->user['username']}</a>

It will display your username with your profile link.
This feature is default in MyBB 1.6.4 template.
(2011-10-11, 06:09 AM)crazy4cs Wrote: [ -> ]alt isn't needed, I don't use it, title can be useful, but I never include alts.

technically speaking, alt is a required attribute. But in practice it only matters if blind people visit your site (or anyone else using a text browser), because it doesn't affect page rendering.
(2011-10-11, 05:18 AM)crazy4cs Wrote: [ -> ]something like:

<img src=\"http://yourimagelink.com\">

(2011-10-11, 05:23 AM)Malcolm. Wrote: [ -> ]
(2011-10-11, 05:18 AM)crazy4cs Wrote: [ -> ]something like:

<img src=\"http://yourimagelink.com\">

Just being picky, but that should be:

<img src=\"http://yourimagelink.com\" alt=\"img\" />

In my global.php now i have something like this
$lang->alternative_welcome = $lang->sprintf($lang->alternative welcome, <img src=\"http://yourimagelink.com/folder/image.png\">, build_profile_link($mybb->user['username'], $mybb->user['uid']));;

When i replace it with the original the forum crashes and it gives me a blank page. It worked before i inserted the image code.
Pages: 1 2