• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

How to expose online members data to custom template?

Matthew Hawley

Well-known member
Could someone give me a tutorial on how to expose online members and members count data to a custom template? I'm pretty sure it has something to do with viewparams...



Well-known member
There is a table called xf_session which logs the sessions of users online currently.Use that table to join with users and grabs the data about members you require.


Well-known member
Also check out the Xenforo Model called Session in the default xf lib. There are a few functions which may help you.


Formerly Nobita.Kun
Look at on XenForo_ControllerPublic_Forum at line:41
'onlineUsers' => $this->_getSessionActivityList(),
And this function:
protected function _getSessionActivityList()
        $visitor = XenForo_Visitor::getInstance();

        /** @var $sessionModel XenForo_Model_Session */
        $sessionModel = $this->getModelFromCache('XenForo_Model_Session');

        return $sessionModel->getSessionActivityQuickList(
            array('cutOff' => array('>', $sessionModel->getOnlineStatusTimeout())),
            ($visitor['user_id'] ? $visitor->toArray() : null)

I think its useful for you :)