View Full Version : Add image next to avatar
Ron G
05-04-2003, 04:30 AM
I am trying to figure out how to add one or more images next to a user's avatar, depending upon whether they belong to specific classes. What I'd like to do is create hidden user profile fields, and then depending on whether a user belongs to one of these categories, a small image will appear next to the user's avatar.
I've seen this on numerous sites, usually for different levels of donars. I just can't figure out how to do it. Does anyone know of any existing hacks for this?
Thanks
CRego3D
05-04-2003, 02:33 PM
maybe the awards hack is what you thinking of ?
Ron G
05-04-2003, 03:35 PM
I found something under "perks" but it doesn't work for vBulletin 2.9
EvilLS1
05-04-2003, 06:07 PM
What do you mean by "depending on whether a user belongs to one of these categories".. By catagories do you mean usergroups? If so, just create the new usergroup, then in functions.php
Find:
eval("\$post[avatar] = \"".gettemplate("postbit_avatar")."\";");
}
Below that add:
if ($post[usergroupid] ==X) {
$image = "<img src=\"http://www.yoursite.com/forums/images/specialimage.gif\">";
} else {
$image="";
}
Just replace the red X with the usergroup ID # for the one you want to have the image. The in the postbit next to the avatar add $image .
You could also do it based on custom profile fields if thats what you mean. But you'd need to add the drop down profile field selection hack first.
Ron G
05-04-2003, 07:40 PM
Thanks for the tip, but I just can't make it work.
I wasn't sure if you meant Postbit or Postbit_avatar, so I tired various combinations with both. This is what I used:
In Postbit
<a name="post$post[postid]"></a>
$post[firstnewinsert]
<normalfont><b>$post[username]</b></normalfont><br>
<smallfont>$post[usertitle]</smallfont><br>
$post[avatar]<br />Feild name: $post[field9]$image
<smallfont>Registered: $post[joindate]<br>
Location: $post[field2]<br>
Posts: $post[posts]</smallfont></td>
In Postbit_avatar
<img src="$avatarurl""$image" $imageborder="0" alt="">
In neither case did it work.
EvilLS1
05-04-2003, 08:51 PM
I meant the postbit, not postbit_avatar.
What exactly did you put in functions.php? Copy and paste it here and I'll tell you why its not working.
Ron G
05-04-2003, 10:26 PM
Thanks,
This is the relevant portion of functions.php:
}
if ($avatarurl=="" or ($bbuserinfo[userid]>0 and !($bbuserinfo[showavatars]))) {
$post[avatar]="";
} else {
eval("\$post[avatar] = \"".gettemplate("postbit_avatar")."\";");
}
if ($post[usergroupid] ==14) {
$image = "<img src=\"http://usslibertyinquiry.com/forums/images/PH.gif\">";
} else {
$image="";
}
EvilLS1
05-04-2003, 11:07 PM
Are you sure that you put the correct usergroup id? I just tested it on my board and it works fine.
Ron G
05-04-2003, 11:38 PM
In Admin, I opened up User Groups and moused over the selected group. Down below, it showed the group id as 14.
In functions.php it is written as "==14" Are there supposed to be two equal signs? Also, is it enough to just use "14" or does it need to be "usergroupid14"?
Finally, in postbit, is this the correct placement of $Image:
$post[avatar]<br />Feild name: $post[field9]$image
Thanks,
Ron
EvilLS1
05-04-2003, 11:51 PM
Your functions.php code is correct. I copied the code from your post and pasted it into my functions.php then changed the usergroupid to 6 (admin) and it worked fine.
Make sure when you add the $image text to your postbit that its all smallcase, just like the code in functions.php. I don't know what else could be causing it not to work for you.
You have actually added some people to the new usergroup, correct? If nobody is in that usergroup then you're not gonna see anything. Just to test it, try changing the usergroup ID to 6.. You should then see the image in all admins posts.
Ron G
05-05-2003, 03:35 AM
Thanks for all of the help, I really appreciate it. I tried changing the group id to 6, but that didn't work. I wonder if the problem could be the size of the two images I'm trying to put in that space. I'm allowing a 100x100 avatar of the user, and the for those who have received the medal, an image of the medal next to their avatar. That image (the one that doesn't show up) is 48 pixels wide. Do you think that could be it? In functions.php, it looks like vBulletin only looks to the first image for size.
EvilLS1
05-05-2003, 03:42 AM
Well, if the image is too big to fit in the table beside the avatar it should be pushed to the next line.
Try putting a <br> in front of $image . I don't really think that will fix anything but I'm out of ideas as to why its not working for ya.
Good luck with it.
Ron G
05-05-2003, 03:52 AM
Thanks for all your help. Unfortunately, this didn't work. I'll try it with a smaller image and see if that works.
By the way, we are talking about side by side images, right?
EvilLS1
05-05-2003, 04:00 AM
Today at 05:52 AM Ron G said this in Post #13 (https://vborg.vbsupport.ru/showthread.php?postid=391620#post391620)
Thanks for all your help. Unfortunately, this didn't work. I'll try it with a smaller image and see if that works.
By the way, we are talking about side by side images, right?
Yes it should work side by side with the avatar..
You did upload functions.php to the admin directory, right? Sorry if I'm asking the obvious, but this should be working for you as it works just fine on my forum.
If you want, you can email me your functions.php and also email me a text file with the entire contents of your postbit in it and I'll add the code or double check your code and send it back to you.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.