View Full Version : if statment for avatars?
indie
02-16-2005, 02:45 PM
Can I use an "if" statement, if the membergroup is not allowed to have avatars or profile pics, but they already uploaded them before the change, so they are showing in the postbit and view profile page, to let them show "if" in a usergroup that allows them.... or have them not show "if" in a usergroup without the permission.... if so, would someone be so kind as to tell me how to do that?
Thanks!
Deaths
02-16-2005, 02:54 PM
Go to ACP-> Styles & Templates -> Edit Templates ->postbit ot postbit_legacy.
Now, find the code for the avatars.
In the postbit template it's this:
<if condition="$show['avatar']"><td class="alt1"><a href="member.php?$session[sessionurl]u=$post[userid]"><img src="$avatarurl" alt="<phrase 1="$post[username]">$vbphrase[xs_avatar]</phrase>" border="0" /></a></td></if>
Now, replace that with:
<if condition="$bbuserinfo[usergroupid]=X">
<else />
<if condition="$show['avatar']"><td class="alt1"><a href="member.php?$session[sessionurl]u=$post[userid]"><img src="$avatarurl" alt="<phrase 1="$post[username]">$vbphrase[xs_avatar]</phrase>" border="0" /></a></td></if></if>
Make sure you replace the X with the usergroup you wish to not allow.
indie
02-16-2005, 03:01 PM
Great thanks!!
Can you post what the replacement is for postbit_legacy, it looks different than that...
And also, if you could if possible, post the replacement I could use on the profile page for the avatr and profile pic?
Thanks!
Deaths
02-16-2005, 03:07 PM
In the postbit_legacy template it's this:
<if condition="$show['avatar']">
<div class="smallfont">
<br /><a href="member.php?$session[sessionurl]u=$post[userid]"><img src="$avatarurl" alt="<phrase 1="$post[username]">$vbphrase[xs_avatar]</phrase>" border="0" /></a>
</div>
</if>
Replace with:
<if condition="in_array($post[usergroupid], array(X,X,X))">
<else />
<if condition="$show['avatar']">
<div class="smallfont">
<br /><a href="member.php?$session[sessionurl]u=$post[userid]"><img src="$avatarurl" alt="<phrase 1="$post[username]">$vbphrase[xs_avatar]</phrase>" border="0" /></a>
</div>
</if></if>
I'll look into the profile now, expect a reply in ~5 minutes.
Ok, mistake fixed.
Ok, edit template MEMBERINFO.
Find:
<if condition="$show['profilepic']">
<td valign="top" align="$stylevar[right]" rowspan="2">
<img src="image.php?u=$userinfo[userid]&type=profile&dateline=$userinfo[profilepicdateline]" alt="<phrase 1="$userinfo[username]">$vbphrase[xs_picture]</phrase>" border="0" style="border:1px solid $stylevar[tborder_bgcolor]" />
</td>
</if>
Replace with:
<if condition="in_array($userinfo[usergroupid], array(X,X,X))">
<else />
<if condition="$show['profilepic']">
<td valign="top" align="$stylevar[right]" rowspan="2">
<img src="image.php?u=$userinfo[userid]&type=profile&dateline=$userinfo[profilepicdateline]" alt="<phrase 1="$userinfo[username]">$vbphrase[xs_picture]</phrase>" border="0" style="border:1px solid $stylevar[tborder_bgcolor]" />
</td>
</if></if>
Now, find
<if condition="$show['avatar']">
<td><img src="$userinfo[avatarurl]" alt="<phrase 1="$userinfo[username]">$vbphrase[xs_avatar]</phrase>" border="0" style="border:1px solid $stylevar[tborder_bgcolor]; border-top:none" /></td>
<else />
<td> </td>
</if>
Replace with:
<if condition="in_array($userinfo[usergroupid], array(X,X,X))">
<else />
<if condition="$show['avatar']">
<td><img src="$userinfo[avatarurl]" alt="<phrase 1="$userinfo[username]">$vbphrase[xs_avatar]</phrase>" border="0" style="border:1px solid $stylevar[tborder_bgcolor]; border-top:none" /></td>
<else />
<td> </td>
</if>
I haven't tried this, but it should work.
Please let me know if it did work, or didn't :)
indie
02-16-2005, 03:22 PM
Wow, you are awesome...
I'm going to try this now... THANKS!
Deaths
02-16-2005, 03:22 PM
No problemo :).
If it doesn't work, please tell me, and I will take a closer look at it.
indie
02-16-2005, 03:23 PM
PS, can usergroup(s) be separated by comma? (I will add banned members too, if so)
Deaths
02-16-2005, 03:31 PM
I have updated my post, now you can!
Just replace the X's with the usergroups you want, and if you wish you can add/remove more numbers!
Examples:
<if condition="in_array($userinfo[usergroupid], array(4,5,6))">
<if condition="in_array($userinfo[usergroupid], array(1,2))">
<if condition="in_array($userinfo[usergroupid], array(1))">
<if condition="in_array($userinfo[usergroupid], array(1,2,3,4))">
indie
02-16-2005, 03:41 PM
I tried what you gave me (original legacy postbit), and everyone's disappeared.
Deaths
02-16-2005, 04:02 PM
Are you sure you added only the banned usergroup?
And the very first code is wrong, it will only display it to banned members.
Very wrong, heh.
Use the code from this (https://vborg.vbsupport.ru/showpost.php?p=612777&postcount=4) post (ie my other post)
indie
02-16-2005, 04:23 PM
Cool, I think this is working for me!
I am using it for banned members, and a usergroup that is not allowed to have avatars, but they show because they had them before I removed the permission.
I tried the postbit_legacy one, and that works.. I'll have to try the others too, thanks for the help!
PS - These members also had signatures removed, but in the profile view page, you still see the signature. I am assuming I can apply that same type of code around the signature area of memberinfo, and that would work?
Thanks again!
Deaths
02-16-2005, 04:34 PM
Yep, you can use the code for the sig aswell.
Keep in mind though, the code for the postbit is differs from the one for the MEMBERINFO template. MEMBERINFO uses $userinfo, while the postbit template uses $post :).
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.