In a discussion titled “Showing Discourse notifications in WordPress?”, user lkramer asks if Discourse notifications can be displayed on a parent WordPress site, noting that while they work natively on the Discourse subdomain, they do not appear on the main domain. codinghorror confirms this is not a built-in feature but suggests it is feasible using the Discourse API to poll for notifications and display them on the WordPress site. lkramer notes they will investigate this further for their decision-making process. The conversation expands when erlend_sh asks if HAWK has implemented this at FeverBee. HAWK confirms it is live but notes the implementation was outsourced, pointing to riking for technical details. riking explains that self-hosted users must enable CORS settings (DISCOURSE_ENABLE_CORS) and can then request the /notifications.json?silent=1 endpoint. HAWK later directs others back to riking’s post for the solution.
Hello! We’re considering the advised setup of WordPress installed on domain.com and discourse installed on community.domain.com and then using the WordPress plugin provided by Discourse for single sign on etc.
Obviously if someone is on community.domain.com they have a “notification” (like someone replied to a thread or what have you) the user will see that notification at the top of the screen.
But what about getting that notification to show up in WordPress? Is this functionality possible? Is it built in to the WordPress plugin already?
We envision our users will spend time on the main domain domain.com reading articles and so forth and we would like them to see any notifications they come up for forum threads they are involved in etc.
It’s a good idea, this has come up before – how do we surface Discourse notifications in the “parent” site – but we’ve never had a big customer seriously interested in pushing it forward, so we haven’t had the resources to work on it.
I do think this would be possible through the existing Discourse API; you could use the API call to poll for notifications for the currently logged in user, and then show them however you like on the parent website.
Pretty sure I’ve seen this in action over at FeverBee, am I right about that @HAWK? If so, maybe you could shed some light on how you’ve got this set up on your end?
Correct, we do have this implemented. I don’t know how it was done because I outsourced it, but my developers took advice from @riking so he might be the best person to answer this.
If not, I’m happy to send them an email and find out what was involved.
You need to set the cors origins site setting, and turn on DISCOURSE_ENABLE_CORS if you’re self-hosted. After that, it should be easy to request /notifications.json?silent=1.