MyBB Community Forums

Full Version: Show users' avatars on the "Who's Online" list
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I thought it would be neat to show a list of very small avatars for each online user, rather than having a wall of text.

I just can't figure out how to get the link to a user's avatar (other than the current user)

Does anyone have any idea how to do this, preferably without taking up too many resources?
Yes, there is a tutorial for it by Yaldaram, here on the site. I will try and find the link.

It looks like this when done:

http://blackcanvas.net/online.php

I use a default avatar for guests.

EDIT: here you go

http://yaldaram.com/thread-3784.html?highlight=online
Thanks for the responses.

Actually, I was talking about the "Who's Online" list on the index page. I'll try this code and see if it works in both places.

EDIT: No such luck :p
I just achieved this modification on localhost. It's up to you to limit the size of the avatars. Smile

1. Modify the query. Open up index.php, around line 66, find:

SELECT s.sid, s.ip, s.uid, s.time, s.location, s.location1, u.username, u.invisible, u.usergroup, u.displaygroup

Replace with:

SELECT s.sid, s.ip, s.uid, s.time, s.location, s.location1, u.username, u.invisible, u.usergroup, u.displaygroup, u.avatar

2. Prep the variables. Find:

					// Properly format the username and assign the template.
					$user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
					$user['profilelink'] = build_profile_link($user['username'], $user['uid']);
					eval("\$onlinemembers .= \"".$templates->get("index_whosonline_memberbit", 1, 0)."\";");
					$comma = $lang->comma;

Replace with:

					// Properly format the username and assign the template.
					// $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
					// $user['profilelink'] = build_profile_link($user['username'], $user['uid']);
					$user['profilepath'] = $mybb->settings['bburl'] . '/' . get_profile_link($user['uid']);
					if(!$user['avatar'])
					{
						$user['avatar'] = $mybb->settings['bburl'] . '/images/default_avatar.gif';
					}
					eval("\$onlinemembers .= \"".$templates->get("index_whosonline_memberbit", 1, 0)."\";");
					$comma = $lang->comma;

3. Open up the index_whosonline_memberbit template. Replace it all with this:

{$comma}<a href="{$user['profilepath']}"><img src="{$user['avatar']}" title="{$user['username']}" /></a>{$invisiblemark}

Done. Smile Users who do not have an avatar get the default_avatar.gif - change this if you want. Smile
Awesome, thanks man. I'll try it when I get home.