Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display Number of Users Online

  • Avatar of eleventwenty2
    ElevenTwenty2
    Member

    @eleventwenty2

    Hi, how would I be able to display the number of users online? I’ve searched all over and couldn’t find anything. I don’t want something like the Who’s Online Widget. I’m just looking for something that’ll say “XX Members Online”.

    Any help is appreciated, thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Avatar of r-a-y
    r-a-y
    Moderator

    @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.

    Avatar of eleventwenty2
    ElevenTwenty2
    Member

    @eleventwenty2

    worked, thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.