MyBB Community Forums

Full Version: Get avatar to show on User CP Latest Threads thread
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey gang, so I'm trying to add last poster avatars to User CP latest thread thread,

What I have is this: lu.avatar
and this: LEFT JOIN ".TABLE_PREFIX."users lu ON (lu.uid = t.lastposteruid)

I add it like so

SELECT t.*, t.username AS threadusername, u.username, lu.avatar
 FROM ".TABLE_PREFIX."threads t
 LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid)
 LEFT JOIN ".TABLE_PREFIX."users lu ON (lu.uid = t.lastposteruid)
 WHERE t.uid='".$mybb->user['uid']."' AND t.firstpost != 0 AND t.visible >= 0 {$visible}{$f_perm_sql}
 ORDER BY t.lastpost DESC
 LIMIT 0, 5
 ");

This works fine to show avatars using {$thread['avatar']} but it won't pull the avatars for users with default avatars, it just appears as <img src(unknown) for default avatars

any suggestion how I can fix this to show default avatars?
Neo's plugin gives you avatars there, in case you're not aware.
Since it looks like you're trying to create this as plugin I would try to check what value you get when user have default avatar from database and build simple code that will replace what is used as default to actual link to default avatar.
I don't remember, but I think that user avatars are saved as links, and default one most likely is empty.
Check that Smile
@Michael2014

I reread your post, if you have that query working to show the avatars then it should be fairly simple. Use an if statement like this:

if(!empty($user['avatar'])) { $user['avatar'] == '<img src="{$user['avatar']}" alt="">'; }
else
{ $user['avatar'] == '<img src="images/default_avatar.png" alt="">'; }