Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Show Real Time Online Users in WordPress

Do you want to show the number of online users visiting your WordPress site? Online users widgets are fairly common for community sites and forums. In this article, we will show you how to display real time online users widget in WordPress.

Users online right now on a WordPress site

Video Tutorial

Subscribe to WPBeginner

If you don’t like the video or need more instructions, then continue reading.

First thing you need to do is install and activate the WP Useronline plugin. Upon activation, you need to visit Settings » UserOnline page to configure the plugin settings.

Users Online plugin settings

On this page, you can change the default plugin settings. These settings include time out, users online page URL, and display settings.

The default settings would work for most sites, so you need to just click on the save settings button at the bottom of the page.

The next step is to create the page where you want to showcase the users who are online right now on your WordPress site. Create a new WordPress page by going to Pages » Add New.

You can use any title for the page, but the page’s URL slug should be the same as you had in the plugin’s settings. Click on the edit button next to the URL slug and change it to useronline.

Edit page slug to useronline

After that you need to add the shortcode [page_useronline] in the content area. You can now publish this page.

Displaying Online Users on the Front-end in WordPress

The plugin provides two ways to display online users on your WordPress site. The first method is recommended for beginners. Simply go to Appearance » Widgets page. Next, drag and drop User Online widget from the list of available widgets to a sidebar.

Users online widget

The other method is to use this code in your theme files where you want to display users online.

<?php if (function_exists('users_online')): ?>
    <p>Users online: <div id="useronline-count"><?php users_online(); ?></div></p>
<?php endif; ?>

Using the second method will allow you to use custom CSS to style it differently.

We hope this article helped you display the number of online users on your WordPress site. You may also want to take a look at out tutorial on how to add a private messaging system to your WordPress site.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

5 CommentsLeave a Reply

  1. Hi there

    Would it be possible if I use this plugin on 2 different sites and want to display the combined total of users on both the sites.


    • You would need to reach out to the plugin’s support for if that is available but not likely at the moment an option for two sites


  2. What I don’t like about this widget/plugin is the output when you click on the link the widget displays. E.g., right now it shows “Useronline” and “1 User Online.” The 1 Useronline is a link anyone can click, the it takes you to a page showing:

    “Users Online Right Now

    There is 1 User online now: 1 Member, 0 Guests and 0 Bots.

    Most users ever online were 1, on May 17, 2015 @ 7:19 pm
    1 Member Online Now

    #1 – Mr. and Mrs. Tango xx.xx.16.222 on May 17, 2015 @ 7:33 pm
    Two or More To Tango » Archive Users Online Right Now – Two or More To Tango [url] [referral]

    (I XXed out the IP address.) I don’t think I want everyone being able to see all of that info.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.