PDA

View Full Version : Way to check for Avatar on FORUMHOME and Postbit?


RedTurtle
11-07-2012, 03:32 PM
Hi guys,

I would like to encourage my users who do not have an avatar set to upload one for themselves. To this end I am looking to see if there is a conditional I can use either on FORUMHOME (maybe via notices manager?) and also in the postbit template that would check if they have an avatar set.

On the postbit I was thinking on their posts, it would show a link in their profile info area telling them to click on a link to set an avatar if they do not already have one, and on FORUMHOME it could show a notice or something asking them to get an avatar.

Is this possible? Thank you! :)

kh99
11-09-2012, 02:33 PM
In the posts you could check $post[postid] == 0 and !$post[hascustomavatar], so you could maybe do this:

<vb:if condtiion="$post[userid] == $bbuserinfo[userid] AND $post[avatarid] == 0 AND !$post[hascustomavatar]">
// Post belongs to logged in user and that user doesn't have an avatar
<vb:else />
// Existing avatar code
</vb:if>



I'm not sure if the same check will work on FORUMHOME because I'm not sure if you have the avatar info by default. If it does work, then it would be something like:

<vb:if condtiion="$bbuserinfo[avatarid] == 0 AND !$bbuserinfo[hascustomavatar]">
// Logged in user has no avatar
</vb:if>

RedTurtle
11-09-2012, 03:51 PM
Thank you kh99! :)

I'm not so concerned about forumhome I suppose. But getting it to work on postbit would be really nice.

Unfortunately I'm having an issue with it working. This is the code I am using:

<vb:if condition="$show['avatar']">
<vb:if condition="$post[userid] == $bbuserinfo[userid] AND $post[avatarid] == 0 AND !$post[hascustomavatar]">
<vb:comment>Post belongs to logged in user and that user doesn't have an avatar</vb:comment>
<a class="postuseravatar" href="/profile.php?do=editavatar" title="Click here to choose your picture!">
<img src="/images/misc/unknown.gif" alt="{vb:rawphrase xs_avatar, {vb:raw post.username}}" title="Click here to choose your picture!" />
</a>
<vb:else />
<vb:comment>Existing avatar code</vb:comment>
<a class="postuseravatar" href="{vb:link member, {vb:raw post}}" title="{vb:rawphrase {vb:raw post['onlinestatusphrase']}, {vb:raw post.username}}">
<img src="{vb:raw post.avatarurl}" alt="{vb:rawphrase xs_avatar, {vb:raw post.username}}" title="{vb:rawphrase xs_avatar, {vb:raw post.username}}" />
</a>
</vb:if>
</vb:if>

but the issue I have is that the image I am trying to get to show up for when a user doesn't have an avatar, isn't showing up. I want that image to be what they click on to take them to the Edit Avatar page but for some reason it isn't showing.

Any idea what I'm doing wrong? Thanks!

kh99
11-09-2012, 03:59 PM
You have this:
<img src="/images/misc/unknown.gif" ...


Are you sure that's the right path to the image? Maybe try taking off the beginning '/' and see if that works. Otherwise, did you check the page html to see if it's what you'd expect?

RedTurtle
11-09-2012, 04:03 PM
Thanks for the response.

I did double check the path, tried removing the leading '/' and even tried an absolute path but it didn't work. Also checking the source html (great idea btw :) ) also doesn't show that portion of code at all which makes me think the conditional isn't working properly?

--------------- Added 1352480907 at 1352480907 ---------------

Update:

If I install this product here: https://vborg.vbsupport.ru/showthread.php?t=227947 then your code works properly but the downside is that it shows a default avatar for every single person who doesn't have one, whereas I want it to only show that avatar to the person logged in, asking them to set a custom avatar.

kh99
11-09-2012, 04:10 PM
OK, yeah, the problem seems to be that $show['avatar'] is false if the user has no avatar, but it can also be false if the logged in user has chosen not to see avatars. So maybe this:

<vb:if condition="$bbuserinfo[userid] <= 0 OR $bbuserinfo[showavatars]">
<vb:if condition="$post[userid] == $bbuserinfo[userid] AND $post[avatarid] == 0 AND !$post[hascustomavatar]">
<vb:comment>Post belongs to logged in user and that user doesn't have an avatar</vb:comment>
<a class="postuseravatar" href="/profile.php?do=editavatar" title="Click here to choose your picture!">
<img src="/images/misc/unknown.gif" alt="{vb:rawphrase xs_avatar, {vb:raw post.username}}" title="Click here to choose your picture!" />
</a>
<vb:else />
<vb:if condition="$show[avatar]">
<vb:comment>Existing avatar code</vb:comment>
<a class="postuseravatar" href="{vb:link member, {vb:raw post}}" title="{vb:rawphrase {vb:raw post['onlinestatusphrase']}, {vb:raw post.username}}">
<img src="{vb:raw post.avatarurl}" alt="{vb:rawphrase xs_avatar, {vb:raw post.username}}" title="{vb:rawphrase xs_avatar, {vb:raw post.username}}" />
</a>
</vb:if>
</vb:if>
<vb:if>

RedTurtle
11-09-2012, 04:15 PM
Thank you again kh99! :)

That did it! :D