SAC Pro provides a shortcode to display the current number of chat messages for any chat room. This quick tutorial explains how it works..

The magic shortcode

To display the current (live) number of chat messages, add the following shortcode to your post or page:

[sacpro_count form_id="WelcomeChat"]

Replace WelcomeChat with your actual form ID.

Important: In order for the shortcode to work, a chat form (with the same ID) must be included on the page. If the chat form does not exist on the page, the shortcode will not work. So for example this will work beautifully:

[sacpro form_id="WelcomeChat"]       // displays the chat form
[sacpro_count form_id="WelcomeChat"] // displays the message count

Notice the form_id attributes match with the same value. Perfect.

Important: The [sacpro] and [sacpro_count] shortcodes can be used only once per page.
Output

The shortcode outputs the number of chat messages in plain text. The number is a “live” count of messages. So as users chat, the number will change dynamically to show the current number of messages.

FYI the count number is wrapped with a <span> like:

<span id="sacpro-chat-count" class="sacpro-chat-count sacpro-chat-count-WelcomeChat">99</span>

So you can style with CSS as desired.

Example

Here is an example of how the message-count shortcode might be used on a page.

[sacpro form_id="WelcomeChat"]

<em>Currently there are [sacpro_count form_id="WelcomeChat"] chat messages.</em>

And the result output will look like:

Currently there are 1,245 chat messages.

Related