Forum breadcrumbs – You are here:Asgaros Support ForumSupportUsers Online Shortcode
Please or Register to create posts and topics.

Users Online Shortcode

Page 1 of 2Next

I would love to list how many users are currently using the forum on my homepage outside of that forum page.

Is there a shortcode or code snippet available where I could post the statistics-element –> element-number?

Hey @pjsullivan75,

you can use the following code snippet to create a shortcode with the online users:

add_shortcode('asgaros-online-users', 'show_online_users');

function show_online_users (){
    ob_start();
    echo '<div id="online-wrapper">';
    global $asgarosforum;
    $asgarosforum->online->render_statistics_element();
    echo '</div>';

    return ob_get_clean();

}

 

Need professional help with Asgaros Forum? Book an appointment with us at domra Web Solutions for setup and customization services. Learn more about our Toolbox for Asgaros Forum plugin to enhance your forum experience.

Thanks! Coffee on its way 😉

qualmy91 has reacted to this post.
qualmy91

While testing the shortcode, I’m showing 0 online users on my test page, but 1 online user (moi) on the forum page.

Hey @pjsullivan75,

thanks for the coffee.

It seems like I missed a line the get the online users. Please try this code instead:

add_shortcode('asgaros-online-users', 'show_online_users');

function show_online_users (){
    ob_start();
    echo '<div id="online-wrapper">';
    global $asgarosforum;
    $asgarosforum->online->load_online_users();
    $asgarosforum->online->render_statistics_element();
    echo '</div>';

    return ob_get_clean();

}

 

Asgaros has reacted to this post.
Asgaros
Need professional help with Asgaros Forum? Book an appointment with us at domra Web Solutions for setup and customization services. Learn more about our Toolbox for Asgaros Forum plugin to enhance your forum experience.
Hi, I see a different number than in the forum. Is the code current?

Is the code still valid? I get an error message when I try to save the code.

David

@moench1987 Can you share some more details about the error?

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Of course: Screenshot

Uploaded files:
  • Asgaros-7.JPG

@moench1987

This code goes to the functions.php of your childe theme (or use a php snippet plugin).

You tried to add it in the customm css section.

Asgaros has reacted to this post.
Asgaros
Page 1 of 2Next