Discourse Who's Online

:discourse2: Summary Discourse Who’s Online displays a list of users currently active on the site
:hammer_and_wrench: Repository Link https://github.com/discourse/discourse-whos-online
:open_book: Install Guide How to install plugins in Discourse

Features

: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

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:

Configuration

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.
  • whos_online_count_only: when enabled, only the count will be displayed. Online user identities will not be revealed

:speech_balloon: Frontend Language Strings

These are available in the admin panel under CustomizeText Content (search for whos_online). These include:

  • 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.
137 Likes

Hello everyone, I recently found the who’s online plugin slows down my site when the number of online users is more than 800. The forum is particularly slow and CPU usage is too high when more than 3000 online users.

After I read the code, the reason is that it will send message to every online user when another user visits the site. Maybe there could be a site setting to make the online updates periodly (e.g. 1 minute), instead of updateing in real-time.

2 Likes

Hi @topological - thanks for the report. What do you have the whos_online_active_timeago setting configured to?

1 Like

I use the default value, 5 minutes

2 Likes

Please, add an option to hide the online status of admins and or specific users or give an option to the user to hide their online status.

I think that is already catered for:

1 Like

Our forum has a lot of lurkers. I was wondering if there was a way to get a count displayed for unregistered users (guests) using this plugin in addition to the users logged in?

I looked at the source a bit and see it basically creates a “channel” using the PresenceChannel functionality. The relevant code block seems to be this

  on(:user_seen) do |user|
    hidden = false
    hidden ||= user.user_option.hide_profile_and_presence if defined? user.user_option.hide_profile_and_presence
    hidden ||= user.id < 0
    next if hidden
    PresenceChannel.new(CHANNEL_NAME).present(user_id: user.id, client_id: 'seen')
  rescue PresenceChannel::InvalidAccess
  end

This adds a user to the PresenceChannel if they are not hidden. It looks like the relevant pieces are whether or not there is a equivalent for on(:user_seen) for guests and whether a PresenceChannel requires a valid user_id. I suppose a dummy ID could be provided but the other challenge is to not double-count guests.

Any thoughts here about the feasibility? I can try to implement it myself if the above challenges have a workaround.

2 Likes

That’s different what If I don’t want to hide my profile and want to just hide my online status?

1 Like

That has been asked before:

2 Likes