Vergessen Sie jetzt das Thema Spam Comment in WordPress 😎

Herunterladen: Vergessen Sie Spam-comment-Plugin

Dies ist ein kostenloses Anti-Spam-Plugin ausschließlich für den Standard commenting System von WordPress.

Wie funktioniert es?

Für fortgeschrittene Benutzer gibt es alternativ die folgende manuelle Methode

Der Standard commenting system of WordPress hat zwei große Probleme.

  1. Anziehungspunkt spam comments.
  2. Keine Folge-E-Mails senden zum comment author (Wird in Kürze diskutiert).

Reden wir über seine Lösungen.

Verhinderung von Spam Comments

Anstatt jedem direkt zu erlauben, die POST request at /wp-comments-post.php wir können eine Logik hinzufügen, um spam zu verhindern comments by 100%.

Schritt 1. Einschränken Comment POST Anfrage Pfad über Query Parameter

Ich werde drei Wege aufzeigen und eine Methode anwenden.

Apache

  • Yoast > Go to Tools > File Editor
  • RankMath > Go to General Settings > Edit .htaccess
  • FTP/SSH > Check /var/www/html
# If Query string doesn't matches return 404
<IfModule mod_rewrite.c>
	RewriteEngine On
        RewriteCond %{REQUEST_URI} .wp-comments-post\.php
        # You may change 45jpfAY9RcNeFP to something else
        RewriteCond %{QUERY_STRING} !^45jpfAY9RcNeFP
	RewriteRule (.*) - [R=404,L]
</IfModule>

Wenn Sie auf LiteSpeed, es unterstützt auch .htaccess file. Sie müssen nach der Implementierung neu starten.

NGINX

location = /wp-comments-post.php {

 if ($query_string !~ "45jpfAY9RcNeFP") {
     return 404;
  }
}

Cloudflare

prevent spam comments
  • Login to Cloudflare Dashboard
  • Go to Firewall > Firewall Rules
  • Create a new firewall rule with below expression
FieldOperatorValue
URIcontainswp-comments-post.phpAnd
URL Query Stringdoes not equal45jpfAY9RcNeFP
  • Choose Action: Block

Am Ende werden Sie sehen, dass der Ausdruck

(http.request.uri contains "wp-comments-post.php" and http.request.uri.query ne "45jpfAY9RcNeFP")

Schritt 2. Korrigieren Sie die Comment POST URL on Scroll event

  • Fügen Sie die folgende Funktion mit Code Snippets plugin oder theme functions.php
  • Achten Sie auf die korrekte Verwendung domain und form ID.
function correct_comment_url_on_scroll() {
// Check if Comment is enabled
if(comments_open()) echo '<script>
let commentForm = document.querySelector("#commentform, #ast-commentform, #ht-commentform");

// Load new comment path on the scroll event
document.onscroll = function () {
    commentForm.action = "https://www.example.com/wp-comments-post.php?45jpfAY9RcNeFP";
};
</script>';
}
add_action('wp_footer', 'correct_comment_url_on_scroll', 99);

Alternativ, wenn Sie ein GeneratePress Premium-Theme sind Benutzer können Sie oben hinzufügen JS teil direkt mit Elements module.

<script>
let commentForm = document.querySelector("#commentform");

commentForm.action = "https://www.example.com/wp-comments-post.php";
// Load new comment path on the scroll event
document.onscroll = function () {
    commentForm.action = "https://www.example.com/wp-comments-post.php?45jpfAY9RcNeFP";
};
</script>
  • Add a new hook
  • New Hook Title: Change Comment URL on the Fly
  • Hook: WP Footer
  • Priority: 99
  • Location: Posts – All posts
  • Publish

Wie kann man überprüfen, ob es funktioniert?

  • Im Allgemeinen gibt WordPress zurück 405 response für GET request at /wp-comments-post.php
  • Aber nach der obigen Einrichtung, sollten Sie sehen Access Denied.
  • Und, the URL sollte nur geladen werden, wenn von besonderen Query String 45jpfAY9RcNeFP die wir hinzugefügt haben, um zu verhindern, dass spam comments. Sie können diese Abfragezeichenfolge in allen oben genannten Konfigurationen in etwas anderes ändern.
  • Der Quellcode zeigt in der Regel wp-comments-post.php path aber wenn Sie das element after scroll you will notice a query string added.

Ergebnis #1: Nein Spam

no spam

Ergebnis#2: Spammers wird blockiert

log

Bonustipp für die Standardeinstellung Comment System even better

  • Unter default WordPress commenting system sendet keine Folge-E-Mails an den Comment Author. Um dieses Problem zu beheben, können Sie Folgendes verwenden Comment Reply Email Notification plugin by Arno Welzel.

Wenn Sie diese Informationen mögen, geben Sie sie bitte an Ihre Freunde weiter. 🙏

Schreibe einen Kommentar

20 Gedanken zu „Vergessen Sie jetzt das Thema Spam Comment in WordPress 😎“

  1. Thank you so much Sir Gulshan Kumar! I really appreciate your guide, and this has saved me tons of headache. Implemented via Cloudflare WAF plus Generatepress Elements Module.

    Antworten
  2. By the way, how do you know if legit users won’t get blocked? Before this, I’ve been using a CF firewall rules that will blocks or challenge anyone who visit wp-comments-post.php but actually by doing so, legit users also got blocked. How this one different? Is it because of the string „45jpfAY9RcNeFP“ that will differentiate which request is from bot and which request is from legit users? If legit users, they should’ve the string, if it’s spam, they don’t have that string. Am I understand it correctly?

    Antworten
  3. Does this plugin / method will stop website from having spam comments once and for all or do we still receive it but it’s automatically filtered from the real comments (like Akismet)?

    Antworten
  4. Hi Gulshan.

    I just wanted to let you know that I’ve been using your plugin for a few weeks now and it is brilliant. Genuine comments still get through but all of the spam, and I mean ALL of it, is filtered out. Excellent job!

    Well done and thank you so much for sharing it for free so that hobby bloggers like me can make use of it.

    Antworten
    • Hi,
      I am also using plugin at this blog. It works perfectly fine here.
      If you want to me look into this issue, please provide your actual site URL where I can see live.
      Thanks!

      Antworten