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.
Video Tutorial
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.
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.
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.
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.
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.
Thanks
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
Is there a way or an addon to set different colors for each user category ?
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.
Jeff contact the plugin author. We are sure if there is enough interest, they would want to extend the plugin in future versions.