MyBB Community Forums

Full Version: Placing User's Avatar around the site.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to work out a way to place a person's selected avatar somewhere else on the site. I've tried copy/pasting the code used, say, in the thread view, and this obviously didn't work.

What I'm trying to achieve, basically, is when viewing as a guest, in the welcome area (the header) you can see a default icon, coupled with your typical "log in or register" prompt. This would be different than any of the icons listed below...

Now, when you log in, and you don't have an icon set, it would display an automatic default icon (which would be the automatic icon given them in their profile, as well.) However, should you have an icon set, I want that displayed instead. This would link to their profile. As well, I want it to be re-sized. In thread view, it would be, say, 200x200, but in the header, no bigger than perhaps 50x50.

Is there any way to do this? And for future reference, is there any way to call a person's specific profile field somewhere in the site it might typically not be?
Something like this?

[Image: minicard.png]

I use PHP in Templates, so you'll need that plugin if you want to use the same method that I do.

This is in the header_welcomeblock_member template.
<if $mybb->user['avatar'] then>
<a href="{$mybb->settings['bburl']}/usercp.php?action=avatar"><img class="float_left post_avatar" src="{$mybb->user['avatar']}" alt="" title="Change Avatar" border="0" width="60" height="60" /></a>

                         <else>

<a href="{$mybb->settings['bburl']}/usercp.php?action=avatar"><img class="float_left post_avatar" src="{$mybb->settings['bburl']}/images/default_avatar.gif" alt="" title="Change Avatar" border="0" width="60" height="60" /></a>
</if>

Edit it to suit your needs. It's basically saying "if user has an avatar, display it. If not, display default_avatar.gif".

For guests, edit header_welcomeblock_guest and instead of using the entire code above, just use the part after <else> to display the default avatar for them.

Also, my code leads to the page to change your avatar when you click on the image. To send them to their profile, use: <a href="{$mybb->settings['bburl']}/user-{$mybb->user['uid']}.html">

You can do this using other methods as well, keep that in mind.
That's actually EXACTLY what I'm looking for!

And which plug-in? I just serached the database and couldn't find one that enabled PHP in templates.

Also, it seems you've found a way to alter how things like $lang->welcome_back show up. Is there a way to do this in the control panel of FTP server, or is that a different deal all together?
Thank you very much! C: