XF 1.4 Adding Time Last Online to Members List

CiaranT

Member
Hi,

In the "notable members" view, each member has number of messages, number of likes, number of trophy points.

How does one add "time last online" to the above list.

Thanks.
 
In function _getNotableMembers() in file XenForo_ControllerPublic_Member you will have to change
Code:
'join' => XenForo_Model_User::FETCH_USER_FULL,
to
Code:
'join' => XenForo_Model_User::FETCH_USER_FULL | XenForo_Model_User::FETCH_LAST_ACTIVITY,

and in template member_list_item you will have to add
HTML:
<xen:if is="{$user.effective_last_activity}"><br /><dt>{xen:phrase last_activity}:</dt> <dd>{xen:datetime $user.effective_last_activity, 'html'}</dd></xen:if>
right after
HTML:
<dt>{xen:phrase trophy_points}:</dt> <dd title="{xen:phrase trophy_points}">{xen:number $user.trophy_points}</dd>

Note that to also add the last activity to the "Staff" tab, you will also have to edit function actionIndex()
change
PHP:
if ($type == 'staff')
{
    $users = $userModel->getUsers(array('is_staff' => true), array(
        'join' => XenForo_Model_User::FETCH_USER_FULL,
        'order' => 'username'
    ));
}
to
PHP:
if ($type == 'staff')
{
    $users = $userModel->getUsers(array('is_staff' => true), array(
        'join' => XenForo_Model_User::FETCH_USER_FULL | XenForo_Model_User::FETCH_LAST_ACTIVITY,
        'order' => 'username'
    ));
}
 
You could turn this into an add-on of course, but that would mean adding an extra query in order to fetch the effective last activity for the resulting users.
 
Top Bottom