Table of Contents
Content Error or Suggest an Edit
Notice a grammatical error or technical inaccuracy? Let us know; we will give you credit!
Introduction
When using the WP Discourse plugin on your WordPress site, you need to ensure that comments are enabled as the WP Discourse plugin will hook into all of the portions of the WordPress comment system. Unfortunately this causes the endpoint for comment posting wp-comments-post.php
to still be active and accepting of requests, which bots will eventually use to try and post comments.
Solutions
1 – WP Discourse
There isn’t a solution within the WP Discourse plugin to block these requests.
2 – Code Snippet to Block wp-comments-post.php
You can use the following code snippet to block the requests, I’ve done minimal testing and it’s worked.
<?php // Block wp-comments-post.php when using WP Discourse plugin - managingwp.io 01-24-2023 function disable_wp_comments_post() { if (basename($_SERVER['PHP_SELF']) === 'wp-comments-post.php') { status_header(403); die(); } } add_action('init', 'disable_wp_comments_post');