Wp-discourse-shortcodes plugin

This is a simple plugin that extends the wp-discourse plugin by adding shortcodes for creating links from WordPress to your Discourse forum.

It adds shortcodes for [discourse_link] , for creating a login link to a specific endpoint on your forum, [discourse_topic] for beginning a pre-filled topic, and [discourse_message] for beginning a private message. See the plugin’s readme for more details. This plugin is only lightly tested, so let me know if you run into problems with it.


I’ve added a [discourse_latest] shortcode. At this point it takes one parameter, max_topics. The topics are cached for 10 minutes. I’m still playing around with the formatting.

The [discourse_groups] shortcode retrieves and displays all groups that are not automatic and are visible. It adds a ‘Request to join’ link at the bottom of each group that creates a private message to the group’s owners. If no owner exists, the request is sent to a site admin. Results are cached for 1 hour, that can be made to be configurable. I’ll add an option to not display the ‘Request to join’ link for specific groups. The plugin’s error handling needs to be improved. There are no styles associated with the plugin. It’s up to the site’s theme to supply them.

The group description is created by creating a topic on Discourse with a title that follows the format ‘About the {group name} group’.

open issues

  • [discourse_topics] shortcodes with different categories do not work correctly.
  • top does not work together with filtering on category

features (roadmap)

  • option to open links in new tab
  • support for filtering by tag

Nice work really like the groups functionality.

Although I am having an issue with that shortcode. It does not seem to update when i make changes to the groups, I also tried adding a description post for and exsiting one and it is not showing up either. Does the plugin cache the information from discourse?

Nevermind just saw this. :grin:


I’m going to add a cache_time option to the [discourse_groups] and [discourse_latest] shortcodes. The groups shortcode needs better error handling. I’ll do it soon because this is something I want to use on a website. I’ll add a [discourse_categories] shortcode later this week.

I would like to make a request to be able to hide some groups from view.

1 Like

Haven’t tried it yet but thanks for this plugin @simon

Instead of just groups, can this plugin also populate posts from discourse using the same group layout?

For example: mark a popular discussion within discourse and get it “pushed” to the frontpage of wp to be shown just like [discourse_groups] with image and teaser intro text.

It seems the lastest version of the WP-Discourse plugin has broke this one. From what I can tell, based on the error i am seeing, is becuase some functions were moved and/or renamed and this plugin is looking in the wrong place for them.

1 Like

Thanks, I forgot about that. I’ll fix it today.


It’s should be working now with the latest release of the wp-discourse plugin. Let me know if you have any problems with it.

I’m going to do some more work on the shortcodes plugin today. The changes will be in the ‘beta’ branch on github.


I’ve done some work on this over the past couple of days. All new work is in the ‘beta’ branch. You can see it here: https://github.com/scossar/wp-discourse-shortcodes/tree/beta

Messages are now created on the WordPress site and sent to Discourse using the API. Messages sent from email addresses that are already associated with a Discourse user are sent from that user. Messages that are sent from email addresses that is not associated with a Discourse user create a new ‘staged’ user. To avoid sending activation emails to the new staged users, I am using this Discourse plugin on my forum: https://github.com/scossar/discourse-staged-user-activation.

The wp-discourse-shortcodes plugin now has four shortcodes, [discourse_link], [discourse_remote_message], [discourse_groups], and [discourse_latest]. See the README for more details.

NOTE: This is still under development, so use at your own risk for now. It’s something that I have some use for. I’ll be working on it as time permits.

Edit: I’m going to change the way the plugin deals with active, non-staged users. It seems wrong to assume that just because someone knows a user’s email address they really are that user.

1 Like

I actually have the groups page only visible to members so the direct pm button is a bit easier instead of the user having to fill out a form. Is there an option to use the previous method?

Yes, that can be done if your site is using SSO with the wp-discourse plugin. Set the ‘remote_message’ attribute to ‘false’. That will add a link to Discourse at the bottom of each group that starts a private message to the group in the Discourse Composer.

Example: [discourse_groups button_text="Join Now" group_list="blues_society,mountain_biking" invite="true" remote_message="false"]

1 Like

I’ve updated the way the discourse_remote_message shortcode handles existing users who are active on the forum. If a form is submitted by an existing, active user, it is not posted through the API, instead, if SSO is enabled, a prefilled message link is created and the user is asked to submit that instead. If SSO is not enabled, the user is instructed to log into the forum to complete their request. The discourse_groups shortcode has the same behaviour - it uses the discourse_remote_message code.
Staged users can still submit forms repeatedly from the WordPress site.

A form that has been completed by an active user:

Because the user is active, instead of posting the form, a message link is created from the its contents.

Awesome work on the plugin. Two things I noticed.

  1. For some reason my First Group on the list does not show the signup section. Just the group info.
  2. using the shortcode you provided with the Remote message turned off the class for the join link has what looks like a double post of the “class” with a space and an extra set of quotes causing the class name to be not recognized so I cannot style it.

It comes up as such:

<a class="class=" wpdc-shortcodes-message-link""="" href="https://forums.grimreapergamers.com/session/sso?return_path=https%3A%2F%2Fforums.grimreapergamers.com%2Fnew-message%3Fgroupname%3DBattlefieldPlayers%26title%3DRequest+to+join+the+BattlefieldPlayers+group">Join Now</a>

Only ‘mentionable’ groups will display a signup form. The cache period for getting the groups is now set to 24 hours. If you make any changes to the groups you will need to add clear_cache="true" to the shortcode attributes for one request.

I think I’ve fixed that in the latest version.

1 Like

For the discourse_groups shortcode I noticed that if I set invite to true and remote message to false the plugin pm’s the groupname so all members of the group get a pm, whereas in a previous version it pm’d just the owner of the group. Is there a way to go back to that? I dont want the enitire group getting a pm when someone requests to join.


Yes, that will cause problems. I’ll change it back to the way it was.

1 Like

Thanks. Much appreciated.

Is your forum set up to allow users to create topics and message by email? It seems that the plugin could take care of all possible use cases if it relied on this.

I’m going to do some work on it tomorrow.

My forum is setup for reply via email but not create via email. I dont have an issue with turning the later on as well.