Who's Online Plugin (discourse-whos-online)

Discourse Who’s Online Plugin

:information_source: Think carefully before installing this plugin. Discourse is designed for asynchronous discussion, and a list of online users can be harmful for some communities

:information_source: This plugin is marked #experimental because it is not optimized for very large forums

discourse-whos-online displays a list of users currently active on the site:

It can also optionally display a user’s online status on their avatar. Either with a “ring”, “glow”, or with a “flair” icon in the top left.
45 39 10

The plugin uses the MessageBus to keep up-to-date, so user status is reflected in real-time. Users which have enabled the “hide profile and presence” setting will not be displayed. You can customize a number of things using the available site settings and language strings:

:wrench: Configuration Options

These are available in the “plugins” section of the admin settings panel.

  • whos_online_active_timeago: maximum “last seen” for which users are considered online (minutes)
  • whos_online_collapse_threshold: number of users before the avatars overlap each other (see gif above). Set very high to disable this feature
  • whos_online_maximum_display: the maximum number of avatars to display. The numeric counter will still count higher than this. The choice of who gets displayed is currently inconsistent
  • whos_online minimum_display: the minimum number of avatars to display. Below this, a “no users online” message is displayed
  • whos_online_hide_below_minimum_display: if enabled, the widget will be entirely hidden when the number of users is less than minimum_display
  • whos_online_display_public: should the plugin be displayed to people who aren’t logged in? Defaults to true.
  • whos_online_display_min_trust_level: the minimum trust level that this plugin is displayed to. Defaults to 0
  • whos_online_avatar_indicator: choose how to display online status on user avatars. Defaults to “ring”
  • whos_online_avatar_indicator_topic_lists: display avatar indicators in mobile topic lists, and the “Categories & Latest” view. Defaults to off.

:speech_balloon: Frontend Language Strings

These are available in the admin panel under Customize–>Text Content (search for whos_online)

  • js.whos_online.no_users | “No users currently online”:The message displayed when the number of users < whos online minimum display setting.
  • js.whos_online.title | “Online ({{count}})”: The text displayed before the list of avatars. {{count}} is the number of users online.
  • js.whos_online.tooltip | “Users seen in the last 5 minutes”: the text displayed on mouseover of the text.

How to Install a Plugin

88 Likes

Maybe put the total number, and show the last 20 or 10 avatars?

Good work btw! I know a lot of people wanted something like this. :thumbsup:

7 Likes

One idea I had was to stack the avatars like this, and then the overlap would vary so that it never gets wrapped onto the next line. That’ll require some kind of CSS wizardry though :wink: Also would have a fairly high bandwidth requirement for very large forums to load all the avatars…

6 Likes

Hi David

Please consider the following:

  1. Add a setting to configure how many users to show

  2. Add a setting to configure the text template of “Online (3)”. For example, the template could be: Online ({number}).

  3. Consider circling avatars with green or orange: green means seen online recently, yellow means everyone else. Always show N users (as by configuration in 1 above), but only some of them circled green (the others circled with orange)


    In this example you can see that only one person was online recently, the others were not, but are still shown ordered by most recent first. This will help to avoid an empty “who’s online” list for forums with little users or at nights.
    I like the idea of using avatars instead of nicknames, so what I propose is that you circle the avatars.

  4. Add a setting to configure how many minutes to consider a user is online.

  5. Add a setting to configure the placement of the “Who’s online” line:

  • at the very top (above logo)
  • under llogo (above menu)
  • under menu
  1. Add a setting to customize the size of the avatar circles

  2. Add a css class to the “Online (3)” div, so that it can be styled easily

  3. Add a setting to configure what should open when avatar is clicked (a user profile card popup, or a user profile page, or any other ideas?)

Thanks for your initiative. I’d give it a go as soon as it is configurable to the extent described above.

If some of these settings do already exist, please consider updating your topic post with more info and screenshots of the settings. Many thanks!

11 Likes

That’s cool! But doable with CSS, and if the user puts a high number on whos_online_active_timeago it will break.

1 Like

Great work on this plugin, @david! Thanks for contributing.

I just tried this out on my site and I like it! Perhaps this could function like the likes functionality? E.g. Just display simple text “40 online in last 5 minutes” which, when clicked, display the full list of who’s online? We don’t always need to or want to know who’s online, but it’s interesting to check from time to time. This could be throttled for the lower trust levels to prevent hitting the server too hard.

From the avatar list that appears a link to the user list could be provided, filtered to today and sorted by days visited: Discourse Meta

Also, I think this feature should be suppressed completely if you are the only person online. It just makes me feel even more lonely to see “Online (1)” and my own avatar. Anyway it’s not helping - I already know I’m online! :wink:

4 Likes

All great suggestions. Unfortunately I doubt I will have time to get many of them done, especially as most of them don’t have any application for my very small (<10 online most of the time) discourse forum.

I’d be more than happy to accept pull requests, or for someone to fork what I’ve got so far :slight_smile:

4 Likes

thanks, david! good to know.

Just noticing a weird bug on my site today - the helper text for the last person listed shows their title and not their name.

1 Like

I confirm that too at my site but, only the last one have name, the rest are having only title.

The mouseover text currently follows the logic here:

When users are initially loaded (on first page load) it only loads essential information, so it always ends up using the username. When new users are added via the messagebus, they are loaded “properly” and so all their info (title, full name, username) is available.

I’ve now hardcoded it to use the username, so should be more consistent :slight_smile:

4 Likes

This looks great :thumbsup:

Do you think it might be worth adding an option so we can restrict who sees depending on their user group (or maybe user ID as well - for testing)?

Also, anyone else think it might be worth incorporating this into the Discourse Meta page somehow?

:slight_smile:

From a privacy point of view, the last-active data is already available publically (e.g. Check out https://meta.discourse.org/groups/trust_level_0/members.json?limit=999 )

In my case, my forum is login only, and the plugin respects that (won’t reveal data to non-logged-in users)

From a testing/UX point of view, restricting to certain users/groups could be useful

I think that has been discussed at length here:

https://meta.discourse.org/t/presence-features-for-forums/12?u=david_taylor

3 Likes

Thanks for the reply :slight_smile:

It wasn’t really from a security perspective, but more from a performance and aesthetic view - don’t think guests will be all that interested in who’s online, and sometimes, it could be good to add this as a perk just for TL3 members or mods (I guess it depends on individual forums - I can see difference use-cases :))

3 Likes

I installed this last night, and I like it. It might be a good idea, though, to hide it entirely when no users are online so that “Online (0):” is not displayed.

2 Likes

Or, perhaps a line replacing it stating “No Members are currently online.”

1 Like

Personally, I’d rather it not show anything at all, so as to not give the impression that the website is inactive. :slight_smile:

3 Likes

That is valid-sounding.

But, consider these two points: A. not showing anything may give the appearance that the feature is not installed onto a forum and thus B. gives the false impression that no one may be online, or may be in the future.

That is what the word “currently” stands for. The word “currently” means “not at this moment, but, wait a bit, and someone may see you and thus they too shall stay on and you will see them in the online list”.

Lo and behold, they are rewarded with more icons–Users–showing up; more of seeing others online since one waited after understanding what “not currently” actually means.

Now that “not currently” status is gone.

I speak in broad applications, and not for any one specific forum and any specific wants it may or may not have.

1 Like

I see your point, but I disagree from a UX perspective.

Agreed. I might fork it depending on the direction @david decides to take it.

I disagree from a psychology perspective, which is what UX is based upon.

1 Like

If you want, i’ve just made some css customizations:

normal state:

On hover

You can change the text for your language if you want.

[code]#whos-online {
text-align: right;
margin-bottom: 10px;
margin-right: 15px;
}

#whos-online a {
margin-right: -15px;
transition: margin-right 0.5s;
}

#whos-online:hover a {
margin-right: 0px;
transition: margin-right 0.5s;
}

// Remove this if you want keep the orignal value
#whos-online span {
display: none;
}

#whos-online:before {
content: “En ligne:”;
}[/code]

13 Likes