Directly reject wordpress blacklist comments

Source: Internet
Author: User
In fact, lunjia didn't want to send new articles so quickly, so they took down all the beautiful and moving Jade photos. we all know that comments on the wordpress blacklist will be automatically marked as spam comments. This is a waste of resources. After all, spam comments are still written into the database. If a large number of spam attacks occur during a concentrated period, this blacklist mechanism does not help protect the database. However

In fact, lunjia didn't want to send new articles so quickly, so they took down all the beautiful and moving Jade photos. we all know that comments on the wordpress blacklist will be automatically marked as spam comments. This is a waste of resources. After all, spam comments are still written into the database. If a large number of spam attacks occur during a concentrated period, this blacklist mechanism does not help protect the database. However

In fact, lunjia didn't want to send new articles so quickly, so they took down all the beautiful and moving Jade photos.
We all know that comments on the wordpress blacklist will be automatically marked as spam comments. This is a waste of resources. After all, spam comments are still written into the database. If a large number of spam attacks occur during a concentrated period, this blacklist mechanism does not help protect the database,
Then I wrote a function to directly reject comments that meet the blacklist conditions and the comments will not be written to the database.

Method A: run the following code on functions. php:

Function xhd_fuckspam ($ comment) {if (is_user_logged_in () {return $ comment;} // no pressure on the login user... if (wp_blacklist_check ($ comment ['comment _ author '], $ comment ['comment _ author_email'], $ comment ['comment _ author_url '], $ comment ['comment _ content'], $ comment ['comment _ author_IP '], $ comment ['comment _ agent']) {header ("content-type: text/html; charset = UTF-8 "); exit ('grass you paralyze spam comment rough ');} else {return $ comment ;}} add_filter ('preprocess _ comment ', 'xhd _ fuckspam ');

Method B: run the following code to throw the comments-ajax.php(Find a place, for exampleChecking comments is too fastAfter that function)

If (wp_blacklist_check ($ comment_author, $ comment_author_email, $ comment_author_url, $ comment_content )&&! Is_user_logged_in () {// log on to the user without pressure... err (_ ('grass you paralyze spam comment rough '));}

The effects and principles of the two methods are slightly different,

  • Method A: click submit → POST → receive rejection message exit → return → the content of the comment box is cleared and the submission interval is reset = submit once.
    Advantage: complete Anti-Virus

  • Method B: click submit → POST rejected → return → the content of the comment box is retained = No submit exists
    Advantages:
    1. Comments save time and effort. I use this method to reject comments in English only. This is because of the high chance of such misjudgment, which saves the time for people to Recomment;
    2. Since there is no POST, database pressure is relatively minimal;

    Disadvantages: Because comments-ajax directly extracts the $ _ POST field from the form, it cannot match the IP address and agent blacklist.

:

You can test it by yourself. Method: Replace the nickname you commented on here BagsOr Louis(These are all in_array In the butterfly blacklist) and then submit the comments. Feel the rest.

Fuck-spam is coded by xiaohudie. Any posts here is one hundred percent original, so please keep my link so as not to hurt this pretty girl

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.