Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Display Number of Users Online


r-a-y
Keymaster

@r-a-y

Here’s a quick snippet you can add in your theme’s functions.php:

`function ray_number_online_users() {
$i = 0;

if ( bp_has_members( ‘user_id=0&type=online&per_page=999&populate_extras=0’ ) ) :
while ( bp_members() ) : bp_the_member();
$i++;
endwhile;
endif;

return $i;
}`

Then you can use it in a template like:

`if ( function_exists( ‘ray_number_online_users’ ) ) echo ray_number_online_users();`

*Sidenote: code could be better. I just modified the code from the online widget.

Skip to toolbar