Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+6 votes
in Plugins by
I am tryign to get all online user list (not current/single user ). It is easy to get current logged in user with qa_is_logged_in but this is not working for all logged in user.

Any advice to get all logged and offline in user list
I found some other way by creating custom column. Will update once finished.

1 Answer

+1 vote

We prepared a script for our q2a website, https://github.com/askdevopsorg/demo/blob/master/scripts/c.php

Live demo at http://www.askdevops.org/

A Simple PHP script to show online user count.

How it works?

JQuery is used to call this file, /c.php

Server side data is stored in qa-cache/mydat.txt


1. Copy the below files to the root of Q2A website



2. Paste the below code where you need to display the online user count

   <script>$(window).on('load', function() {$("#_c1").load("/c.php");});</script><span id="_c1">..</span>

edited by
i tried it but it stick on 0 online
Thanks, I see the issue, you have to reload the page to display the current count!
I will fix it
i have figured the problem
i'm using a local server so this line


will not work probably ... i'm using this code to get the rial visitors IP

// Function to get the client ip address
function get_client_ip_env() {
    $ipaddress = '';
    if (getenv('HTTP_CLIENT_IP'))
        $ipaddress = getenv('HTTP_CLIENT_IP');
    else if(getenv('HTTP_X_FORWARDED_FOR'))
        $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
    else if(getenv('HTTP_X_FORWARDED'))
        $ipaddress = getenv('HTTP_X_FORWARDED');
    else if(getenv('HTTP_FORWARDED_FOR'))
        $ipaddress = getenv('HTTP_FORWARDED_FOR');
    else if(getenv('HTTP_FORWARDED'))
        $ipaddress = getenv('HTTP_FORWARDED');
    else if(getenv('REMOTE_ADDR'))
        $ipaddress = getenv('REMOTE_ADDR');
        $ipaddress = 'UNKNOWN';
    return $ipaddress;

i tried every single line but didn't work also ..
can you update the function so can every 1 use it
Thanks again, I have updated the script., you may edit in github too, please join me there..
i have updated the file but still stuck on Online: 0