MyBB Community Forums
Get the url of a users avatar given their uid or username? - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: 1.8 Support (https://community.mybb.com/forum-175.html)
+--- Forum: General Support (https://community.mybb.com/forum-176.html)
+--- Thread: Get the url of a users avatar given their uid or username? (/thread-207282.html)



Get the url of a users avatar given their uid or username? - ConnerKid - 2017-01-10

Is there a way to get the avatar url of a user given either their uid or username? This will not necessarily be the logged in user.


RE: Get the url of a users avatar given their uid or username? - WallBB - 2017-01-10

You can get the avatar of a user using the below code :-
{$mybb->user['avatar']}

Regards
WallBB


RE: Get the url of a users avatar given their uid or username? - ConnerKid - 2017-01-10

(2017-01-10, 10:42 AM)WallBB Wrote: You can get the avatar of a user using the below code :-
{$mybb->user['avatar']}

Regards
WallBB
 That gets the avatar of the currently logged in user, how do I get the avatar of any user given either their username or uid?


RE: Get the url of a users avatar given their uid or username? - dragonexpert - 2017-01-10

$query = $db->simple_select("users", "avatar", "uid=$uid");
$avatarurl = $db->fetch_field($query, "avatar");

Note that avatars don't use a full path url when uploaded;, they use a relative path.