PDA

View Full Version : User's avatar on a page


hitmann
05-27-2008, 02:25 AM
When a user logs in, how do you make their avatar show on a specified location of forum?

veenuisthebest
05-27-2008, 02:32 AM
you'll have to use something like this at the desired location

<td class="$bgclass">

<if condition="!$show['guest']">

<if condition="$avatarurl">
<a href="$vboptions[bburl]/profile.php?$session[sessionurl]do=editavatar"><img src="$avatarurl" border="0" alt="$vbphrase[edit_avatar]" /></a></if></if>
</td>

hitmann
05-27-2008, 05:40 AM
That didn't do it. I have nothing showing up on the forum after pasting this in the header

veenuisthebest
05-27-2008, 11:54 AM
that code i simply copied from the vbadvanced page...

okay try this then, this is from the postbit template

<if condition="$show['avatar']"><td class="alt2"><a href="member.php?$session[sessionurl]u=$post[userid]"><img src="$post[avatarurl]" $post[avwidth] $post[avheight] alt="<phrase 1="$post[username]">$vbphrase[xs_avatar]</phrase>" border="0" /></a></td></if>

Dismounted
05-27-2008, 12:58 PM
That will not work, as the variables required in that statement do not exist until you view a post. You need to create a plugin to fetch the avatar URL, then use that URL.

hitmann
05-27-2008, 07:46 PM
Wow, that would be too advanced for me.
I guess I'd have to look for something else.

MoT3rror
05-27-2008, 08:21 PM
This is what I do for the user avatar on every page.

Put this in your config.php

define('AVATAR_ON_NAVBAR', true);


Create new hook with this info.
Hook Location: fetch_userinfo
Execution order: 5
PHP code: if(defined('AVATAR_ON_NAVBAR') AND ($option & FETCH_USERINFO_AVATAR) AND $vbulletin->options['avatarenabled'])
{
require_once(DIR . '/includes/functions_user.php');
fetch_avatar_from_userinfo($user, false, true);
}
Plugin Active: yes

Also I am using 3.7.0 for the moment and it is working. I just download 3.7.1 about 2 hours ago and haven't got to it yet.

GameWizard
05-27-2008, 10:19 PM
Just out of curiosity, could you explain what the 3 array items refer to and where they are defined?

fetch_avatar_from_userinfo($user, false, true);

MoT3rror
05-27-2008, 10:37 PM
In the function fetch_userinfo(), the userinfo is contain in $user. The second parameter is to fetch the avatar thumb. The third parameter is return fake avatar or no avatar. You can read more info about fetch_avatar_from_userinfo() here. (http://members.vbulletin.com/api/vBulletin/_includes---functions_user.php.html#functionfetch_avatar_from_ userinfo)

hitmann
05-27-2008, 11:33 PM
I don't get it.. I've done how you said and it's still not showing anything :S

MoT3rror
05-28-2008, 04:18 AM
Are you using $bbuserinfo[avatarurl] in your template?

Shaliza
05-28-2008, 05:13 AM
Will this also work for non-vB pages?

MoT3rror
05-28-2008, 05:29 AM
I am currently still in development stage of my new site but it is working on every vbulletin power page that is using the template system in my new site so far.

hitmann
05-28-2008, 05:36 AM
Are you using $bbuserinfo[avatarurl] in your template?

Just added and it's now showing this in text:
customavatars/avatar1_1.gif

MoT3rror
05-28-2008, 05:47 AM
<img src="$bbuserinfo[avatarurl]" border="0" />
If you are using file system avatars use this code.
<img src="$vboptions[avatarurl]$bbuserinfo[avatarurl]" border="0" />

hitmann
05-28-2008, 05:52 AM
I'm using the file system, and nothing appears with the second code.
Would it work on a local installation? And can I put the config.php line that you gave above anywhere in the file?

MoT3rror
05-28-2008, 06:52 AM
I'm using the file system, and nothing appears with the second code.
Would it work on a local installation? And can I put the config.php line that you gave above anywhere in the file?

Yes that line of code should go at the end of the config.php file but it real doesn't matter where it is put as long as you don't get a php error. Also I know it isn't a php problem because the php is working correctly because it is returning a correct path I believe. There is a problem with the html that I can't think of right now. Are you trying this in the same directory as your forums or a file outside of your forums?

I guess that is what you get when you stay up to about 3 am in the morning.

hitmann
05-28-2008, 06:58 AM
Yes, it's in the same directory. I'm trying to add the avatar next to the logo.

--------------- Added 1211968263 at 1211968263 ---------------

I've installed this mod and looks like it's working on 3.7.1:
https://vborg.vbsupport.ru/showthread.php?t=99498