Hello There, Guest! › Register

MySubscriptions 2.2 released.
Looking for a custom plugin for your site? Ask here for a quote.

Adding user avatar in Who's Online list
#1

Does anyone know how I can add user avatars (at a smaller size) in the who's online list along with the username?

I have taken a look at the functions_online.php to see if I can add some code to include the users avatar into the profile link but it has not worked.

Any help at all would be much appretiated.

Thank You.
[Image: eternalwolfsig.php]
#2

EDITED!

READ THE PIRATA NERVO POST. Don't use this old code xD
#3

Do not use the code above, the query is being removed for some reason and it won't work.
Anyway, this has been requested by some people already via PM so I'm going to post it now so next time they dont need to pm me.

Open Index.php (in case User appearance is enabled, skip these 2 edits, I provide modified ones below)
find:
Code:
    $query = $db->query("
        SELECT s.sid, s.ip, s.uid, s.time, s.location, s.location1, u.username, u.invisible, u.usergroup, u.displaygroup
        FROM ".TABLE_PREFIX."sessions s
        LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid)
        WHERE s.time>'$timesearch'
        ORDER BY u.username ASC, s.time DESC
    ");
replace with:
Code:
    $query = $db->query("
        SELECT s.sid, s.ip, s.uid, s.time, s.location, s.location1, u.username, u.invisible, u.usergroup, u.displaygroup, u.avatar
        FROM ".TABLE_PREFIX."sessions s
        LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid)
        WHERE s.time>'$timesearch'
        ORDER BY u.username ASC, s.time DESC
    ");
find:
Code:
                    $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
                    $user['profilelink'] = build_profile_link($user['username'], $user['uid']);
replace with:
Code:
                    //$user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
                    
                    if ($user['avatar'] != "")
                        $user['profilelink'] = "<a href=\"member.php?action=profile&amp;uid={$user['uid']}\"><img src=\"".htmlspecialchars_uni($user['avatar'])."\" width=\"50\" height=\"50\" title=\"{$user['username']}\" ></a>";
                    else $user['profilelink'] = "<a href=\"member.php?action=profile&amp;uid={$user['uid']}\"><img src=\"images/avatar.png\" width=\"50\" height=\"50\" title=\"{$user['username']}\" ></a>";

                    //$user['profilelink'] = build_profile_link($user['username'], $user['uid']); // we build the profilelink above with the avatars

Open Index.php (in case User appearance is enabled, do these edits)
find:
Code:
    $query = $db->query("
        SELECT s.sid, s.ip, s.uid, s.time, s.location, s.location1, u.username, u.invisible, u.usergroup, u.displaygroup, u.buformat, auformat
        FROM ".TABLE_PREFIX."sessions s
        LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid)
        WHERE s.time>'$timesearch'
        ORDER BY u.username ASC, s.time DESC
    ");
replace with:
Code:
    $query = $db->query("
        SELECT s.sid, s.ip, s.uid, s.time, s.location, s.location1, u.username, u.invisible, u.usergroup, u.displaygroup, u.buformat, auformat, u.avatar
        FROM ".TABLE_PREFIX."sessions s
        LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid)
        WHERE s.time>'$timesearch'
        ORDER BY u.username ASC, s.time DESC
    ");
find:
Code:
                    $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup'], $user['buformat'], $user['auformat']);
                    $user['profilelink'] = build_profile_link($user['username'], $user['uid']);
replace with:
Code:
                    //$user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup'], $user['buformat'], $user['auformat']);
                    
                    if ($user['avatar'] != "")
                        $user['profilelink'] = "<a href=\"member.php?action=profile&amp;uid={$user['uid']}\"><img src=\"".htmlspecialchars_uni($user['avatar'])."\" width=\"50\" height=\"50\" title=\"{$user['username']}\" ></a>";
                    else $user['profilelink'] = "<a href=\"member.php?action=profile&amp;uid={$user['uid']}\"><img src=\"images/avatar.png\" width=\"50\" height=\"50\" title=\"{$user['username']}\" ></a>";

                    //$user['profilelink'] = build_profile_link($user['username'], $user['uid']); // we build the profilelink above with the avatars

Note: images/avatar.png is the default image for those that don't have an avatar
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.
#4

Thank You! Once again you have come through for me! I have modified your code to also display the username under the avatar. Also encased it in divs and added come css styling to make all elements clean looking and not so scattered and displaced.

Thank you for your help.
-EternalWolf

http://www.eternalwolf.com/
[Image: eternalwolfsig.php]
#5

No problem, looks much better than mine. I'll modify mine as well Tongue
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.
#6

Eternalwolf could you share that edition?
And nervo...can i use the one posted in post #3?

[Image: glas.png]
#7

Sure feel free to use it.
I think eternalwolf's "edition" has some problems when there are at least 2 users online. @ew did you read my pm?
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.
#8

Cool I might use this thingy...
[spoiler=Join System Chat Forum!!]
[Image: Forum%20Logo.png]
[/spoiler]
#9

(09-01-2009, 08:04 AM)Glas Wrote: Eternalwolf could you share that edition?
And nervo...can i use the one posted in post #3?

I'll give you anything you might need. But unfortunatly, I am not sure as to what you are referring to as "that edition".

Can you please be more specific as to what you would like, I would be more than happy to post back with your request.

Regards,
Vince Marra
EternalWolf,inc.
Owner/Developer
[Image: eternalwolfsig.php]
#10

As the new posts were not here in the databae backup I've just restored, can you please share with us your code please?
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.




Users browsing this thread: 1 Guest(s)