Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display Number of Users Online

  • @eleventwenty2

    Member

    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)
  • @r-a-y

    Keymaster

    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.

    @eleventwenty2

    Member

    worked, thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display Number of Users Online’ is closed to new replies.
Skip to toolbar