• Resolved AndreiD

    (@andreiro37)


    Hi, i want to display only the number of active (online users).
    “custom text XX custom text” – where XX is ja simple number of %COUNT_ACTIVE_USERS% (example 5, 7, 11 ..)

    How can i do it? (i know some php and how to use shortcodes)

    thanks!

    • This topic was modified 7 years, 6 months ago by AndreiD.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Jake Hall

    (@geekserve)

    Hi Andrei,

    So based on my understanding you’d only like to display the number of users whom are online rather than the list of whom?

    If so, that is not currently part of this plugin however I will consider it for a future version, so you can have the choice of a simple vs enhanced statistics widget.

    – Jake

    Thread Starter AndreiD

    (@andreiro37)

    Yes, i need only to echo $number_of_online_users
    Isnt any variable for this? I know some php. (i do not need to display all statistics for the moment)

    thanks in advance

    Plugin Author Jake Hall

    (@geekserve)

    Hi Andrei,

    This is quite hacky, I will try to incorporate some loose API-esque functions in the next veersiokn to avoid this… hackery! I will make it so the API functions will need to be activated, for those whom are worried about performance etc.I never built this plugin with the intention of it being used in such a way, but, as there have been multiple requests for this sort of functionality I will ensure to encorporate this into a future version.

    If you add the following to your functions.php file, you will be able to get a jist of what is happening and where the relevant data you need is. I have setup this example to include all of the relevant variables (users, posts and activity).

    You could potentially hook this into a new widget, or setup a function and simply call it from your php file – down to you on that one.

    function wp_28372873_bbpas_stats() {
    	$stats = bbPress_Advanced_Statistics::instance( __FILE__, BBPAS_VERS );
    
    	$activity_time = $stats->online->parent->option["user_activity_time"];
    	
    	$online_stats = $stats->online->whois_online();
    	$online_stats = array( "inactive" => count( $online_stats["inactive"] ), "active" => count( $online_stats["active"] ) );
    
    	$formatted_stats = $stats->online->get_formatted_statistics();
    	
    	echo "There has been {$online_stats['inactive']} users logged in over the past {$activity_time} hours, of which {$online_stats['active']} are currently active.";
    	echo "There are {$formatted_stats["user_count"]} users registered, we have {$formatted_stats["topic_count"]} topics and {$formatted_stats["reply_count"]} replies!";
    }
    add_action( 'init', 'wp_28372873_bbpas_stats' );

    Or, alternatively, wait a few weeks until I get round to incorporating some API-esque functions into the next release.

    Hope that helps!

    Jake

    Thread Starter AndreiD

    (@andreiro37)

    Thanks, this worked well. I work on a client site and he wanted to display this number on BBpress forum.

    Will be great to make available shortcodes of php functions to get all statistics items as separate things, in ordr to combine and use them as you want.

    I will update the script when you will update the plugin, untill then i will give a 5 stars review.

    thanks

    Plugin Author Jake Hall

    (@geekserve)

    Hi Andrei,

    Thank you very much!

    I anticipate that update will be a big update as I want to completely rewrite that part of the plugin, so, I imagine the code above will not work.

    Nontheless, there will be API functions in place to allow this sort of behaviour in a cleaner manner.

    Thank you for the review, I really appreciate it!

    Jake

    Thread Starter AndreiD

    (@andreiro37)

    Hi, i noticed on the development site that site crach after plugin update. Is an easier way to display the number of Online users with this new version? thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Display only the number of active users’ is closed to new replies.