MyBB Community Forums

Full Version: Status Icon On Memberlist Page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello
I want to show status icon (online/offline or away) of every user on memberlist page.

How can I do that?

Thanks in advance.
hey

open ./memberlist.php

find
eval("\$member .= \"".$templates->get("memberlist_row")."\";");

Above it add

$timesearch = time() - $mybb->settings['wolcutoffmins']*60;
	$online = '';
	$session_query = $db->query("SELECT * FROM ".TABLE_PREFIX."sessions WHERE time>'$timesearch' AND uid='".$users['uid']."' LIMIT 0,1");
	if($db->num_rows($session_query) > 0)
	{
		$online = "ONLINE";
	}
	else
	{
		$online = "OFFLINE";
	}
You might need to custimize the output abit instead of text to images, it depend on what you want.


in Admin CP > Templates >  Modify /Delete > Member list templates > memberlist_row template

find
<td class="trow2">{$users['postnum']}</td>
below it add
<td class="trow2">{$online}</td>


Now in Admin CP > Templates >  Modify /Delete > Member list templates > memberlist Template

find
<td class="tcat"><span class="smalltext"><strong>{$lang->posts}</strong></span></td>
below it add
<td class="tcat"><span class="smalltext"><strong>Status</strong></span></td>
also find
colspan="6"

2 times and replace it with
colspan="7"


regards
if(mysql_num_rows($session_query) > 0)
Should be:
if($db->num_rows($session_query) > 0)
LOL it still works.. i have only used the raw function not the one of mybb.. Toungue well it works tho Toungue
You should use the mybb functions because you do not have the added capability to use mysqli if you don't.
Oh well i usually do Toungue but i was too lazy this time to remember how the function looks like after all this time awayToungue .. fixing my code.
Thank you very much.

But this doesn't show AWAY.
How can we show if any user is AWAY?
LOL alright away..

so instead of

$timesearch = time() - $mybb->settings['wolcutoffmins']*60;
    $online = '';
    $session_query = $db->query("SELECT * FROM ".TABLE_PREFIX."sessions WHERE time>'$timesearch' AND uid='".$users['uid']."' LIMIT 0,1");
    if($db->num_rows($session_query) > 0)
    {
        $online = "ONLINE";
    }
    else
    {
        $online = "OFFLINE";
    } 

use

if($users['away'] == "yes")
	{
		$online = "AWAY";
	}
	else
	{
		$timesearch = time() - $mybb->settings['wolcutoffmins']*60;
		$online = '';
		$session_query = $db->query("SELECT * FROM ".TABLE_PREFIX."sessions WHERE time>'$timesearch' AND uid='".$users['uid']."' LIMIT 0,1");
		if($db->num_rows($session_query) > 0)
		{
			$online = "ONLINE";
		}
		else
		{
			$online = "OFFLINE";
		}
	}
You could just add, above the eval line.
if($users['away'] == "yes")
{
	$online = "AWAY";
}
else if($users['lastactive'] > time() - $mybb->settings['wolcutoff'])
{
	$online = "ONLINE";
}
else
{
	$online = "OFFLINE";
}
Then you don't have to run another query.
Great work.
Thank you so much.