Wie ersetzt Discourse genau WP-Kommentare?

We are using Discourse instead of WP comments (“Remove WordPress Comments Template” is checked, as well as Ajax). I have Toolset Access control on a custom post type that is posting to Discourse (to a private category that aligns with the access control). Normally this type of control would also affect visibility of the post comments, but it’s not affecting the display of the Discourse comments. Any ideas?

1 „Gefällt mir“

Perhaps I can add some further context here:

We have a private custom post type on our Wordpress site, whose posts should be connected with topics in a private Discourse category. The same users who have access to the Discourse category have access to the post on Wordpress. We are handling this by assigning these users to the Editor role in Wordpress, while in Discourse they belong to a group which gives them access to the private category.

In no case should unauthenticated users see either the posts in Wordpress or the topic threads in Discourse. This is working as intended through role and group access controls, respectively. On the Wordpress side, as noted above, we are using Toolset Access to restrict access to all posts of this custom post type.

However, private discussion threads from Discourse are displaying to the public via embedding in Wordpress, even though the post content itself is hidden. In other words, the embedded Discourse comments are not being hidden by access control. We are trying to figure out what might be placing this output outside the control loop, and how to rectify.

The WP Discourse plugin displays comments by loading a custom comments template. It uses the WordPress comments_template filter to load the custom template. I’m not sure why the comments are still loading when you have Toolset Access control configured for a post type. I’ll look into what is going on with that.

I think the plugin should add an option to not load comments for posts that have been published to a private Discourse category. When enabled, just a link to the Discourse topic would be displayed. I’m not sure that would solve the issue you’re dealing with though.

2 „Gefällt mir“

Hi Simon, I’m working with@Kayla on this. What you describe here would solve our issue.

It still would be good to know, too, how to include the Discourse comments template within our more granular access control. Thanks!

1 „Gefällt mir“

Great! I don’t think there will be a problem to get that into the next update of the plugin. I’ll try to have that done by the end of the week. I’ll keep you posted about progress on that.

I think the issue that you’re running into is related to the priority that WP Discourse is hooking into the WordPress comments_template filter hook. The WP Discourse plugin is using a priority of 20 for calling the function that hooks into this filter. The Toolset plugin is probably hooking into that filter with a lower priority to prevent the comment template from being loaded for protected pages.

3 „Gefällt mir“

I got in touch with Toolset about this and I was mistaken about the expected behavior. The Toolset Access plugin doesn’t hook into the comments template at all. Hiding comments on restricted content requires custom code to hook into their toolset_access_api_get_post_permissions filter to suppress/allow the rendering of the comments template at the theme level. I apologize that I did not realize their content restriction is quite literally about the content template itself. :woman_facepalming:

2 „Gefällt mir“

Diese Option wurde in Version 2.0.7 zum Plugin hinzugefügt. Sie ist jetzt im WordPress-Repository verfügbar.

Wenn Sie die Plugin-Option „Discourse-Kommentare aktivieren

3 „Gefällt mir“

Die Änderungen, die ich mit diesem Update sehe, sind: Während discourse_replies_html wie erwartet lädt und angezeigt wird, scheint discourse_no_replies_html nicht geladen zu werden (ich sehe den Textlink „Join Discussion Link: no Comments“, aber nicht unsere Vorlage). Außerdem erscheint bei Beiträgen, die noch nicht in Discourse veröffentlicht wurden, eine neue Meldung: „Comments are not currently available for this post.“ Dabei handelt es sich um öffentliche Beiträge in öffentlichen Discourse-Kategorien.

Bei Beiträgen, die in eine private Discourse-Kategorie veröffentlicht wurden, scheint das Standard-WP-Kommentarformular geladen zu werden. Es gibt keinen Link zum Discourse-Thema.

„Display comments for public topics“ ist aktiviert, ebenso wie „Display Subcategories“. Ich habe „Clear Cached Comment HTML“ und „Force Category Update“ ausgeführt. Übersehe ich etwas?

2 „Gefällt mir“

[quote=“Kayla, Beitrag: 8, Thema: 157969”]
Wenn der Beitrag noch nicht in Discourse veröffentlicht wurde, erscheint eine neue Meldung: „Kommentare sind für diesen Beitrag derzeit nicht verfügbar.

3 „Gefällt mir“

Das ist es, was ich sehe, wenn ich die Option „Kommentare für öffentliche Themen anzeigen

Wir sind bei Version 2.1.1 mit WP 5.5. Das Kommentarcaching ist nicht aktiviert, und wir verwenden keine WP-Kommentare (aber jetzt wird das Standardformular nicht mehr geladen, was gut ist).

Manchmal werden jedoch die benutzerdefinierten Vorlagen geladen und manchmal nicht. Wir haben zurückgesetzt, um Kommentare für alle Beiträge anzuzeigen, unabhängig davon, ob das Discourse-Thema privat ist oder nicht, aber das hat nicht geholfen. Ich kann den Grund nicht herausfinden, aber es scheint bei den einzelnen Beiträgen beharrlich zu sein. Beispiele für öffentliche Beiträge in öffentlichen Themen:

Keine Kommentare, discourse_no_replies_html wird nicht geladen:

Keine Kommentare, discourse_no_replies_html wird geladen:

Hat Kommentare, discourse_replies_html wird nicht geladen:

Hat Kommentare, discourse_replies_html wird geladen:

Es ist möglich, dass das Problem mit den benutzerdefinierten Vorlagen zusammenhängt, aber es gibt einen weiteren Bericht über ein Problem, bei dem die Kommentavorlage nicht geladen wird und stattdessen der Kommentarlink angezeigt wird. Ich kann das Problem auf meiner Entwicklungsumgebung nicht reproduzieren, werde aber eine kleine Änderung am Plugin vornehmen, die das Problem beheben sollte. Das wird bis morgen früh fertig sein. Vielen Dank für eure Geduld dabei!

1 „Gefällt mir“

Könntest du versuchen, das Plugin auf Version 2.1.2 zu aktualisieren und mir mitteilen, ob das Problem damit behoben ist?

2 „Gefällt mir“

Ich kann bestätigen, dass das Update auf 2.1.2 das Problem mit dem Laden der Vorlage für uns behoben hat. Vielen Dank!

2 „Gefällt mir“

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.