How to block wordpress spam messages

Source: Internet
Author: User
Tags php file

Anyone who has installed WordPress knows that the latest versions all come with the Akismet anti-spam comment plug-in, but you need to apply for a key to enable it officially. If you want to follow the prompts to apply, it is found that one of the steps in the application process cannot be opened, and Akismet immediately determines that it is a spam, but it still writes the spam message data to the database, which consumes a lot of resources. Therefore, rue is ready to give up using this plug-in.

Use the spam filter plug-in

Finally selected[Some Chinese Please]This plug-in is very effective for English spam messages. It will judge whether the content contains Chinese characters during the message submission process. If it does not exist, an error message will be returned and the message will not be written into the database, in this way, the spam message is reduced by more than 90%.

[Some Chinese Please:

A necessary defense spam plug-in for blogs written in Chinese. This is a defense spam plug-in for friends who write in Chinese. It can effectively intercept comment and trackback (pingback) with no text in the content, and does not write it into the database. It can effectively reduce spam's unnecessary use of the blog server.

Click install plug-in under the wordpress background menu, and search for Some Chinese Please. The first result is the plug-in, written by binggu. You can also download the installation, download address: http://wordpress.org/plugins/some-chinese-please/

This wordpress tutorial is here, and the installation steps are cumbersome. If you don't understand it, you can leave a message. Happy club will reply to you immediately. After installation, you can modify some simple functions in SCP Setting under "Settings" in the wordpress background.


Use custom code to filter out junk code

First, I am targeting English spam messages.

The code modification method is good. Add the following code at the beginning of the functions. Php file of the current topic style:

The code is as follows: Copy code

Function scp_comment_post ($ incoming_comment ){
$ Zhcn = '/[1-?] /U ';
If (! Preg_match ($ pattern, $ incoming_comment ['Comment _ content']) {
Wp_die ("You shocould type some Chinese word in your comment to pass the spam-check!
<Br/> Sorry, the blog only supports Chinese comments. Please make sure your comments contain Chinese! ");
 }
Return ($ incoming_comment );
}
Add_filter ('preprocess _ comment', 'scp _ comment_post ');

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.