The following column WordPress Website Building Tutorial will introduce to you how to solve the problem of spam comments being sent in groups in WordPress. I hope it will be helpful to friends who need it!
Many of our netizens have reported that during the process of building a WordPress website, they found that there are a lot of spam comments in the background comments every day, and it seems that these comments are not sent manually. Indeed, we may encounter a lot of spam comments sent by software. For example, we may see a lot of English messages. This information will increase our daily deletion time cost, and it is also not good for the website. Is there any way we can solve this problem?
Our most likely method is to add comment verification. You need to enter a verification code or other verification mechanisms when commenting. These are also good methods. Today, what we need to introduce in our WordPress class is how to block these comment contents through two pieces of code.
First, the comment content needs to be in Chinese
What we see in the comments are all in English or other languages, not Chinese. Then we must comment in Chinese.
// 评论中需要有中文 cnwper.com function wp_refused_spam_comments($comment_data) { $pattern = '/[一-龥]/u'; $jpattern = '/[ぁ-ん]+|[ァ-ヴ]+/u'; if (!preg_match($pattern, $comment_data['comment_content'])) { err(__('评论中需要有一个汉字!')); } if (preg_match($jpattern, $comment_data['comment_content'])) { err(__('不能有日文!')); } return ($comment_data); } add_filter('preprocess_comment', 'wp_refused_spam_comments');
Second, prohibit links in comments
Many people leave comments on blogs to promote the website. If we prohibit links, not many people will leave comments.
//禁止发链接 cnwper.com function wp_comment_post( $incoming_comment ) { $http = '/[href="|rel="nofollow"|http://|</a>]/u'; if(preg_match($http, $incoming_comment['comment_content'])) { err( "禁止发链接地址!" ); } return( $incoming_comment ); } add_filter('preprocess_comment', 'wp_comment_post');
It’s as simple as adding two pieces of code to the Functions.php file in your current WordPress theme.
For more WordPress technical articles, please visit the WordPress Tips column!
The above is the detailed content of Solve the problem of mass spam comments in WordPress. For more information, please follow other related articles on the PHP Chinese website!

Can learn WordPress within three days. 1. Master basic knowledge, such as themes, plug-ins, etc. 2. Understand the core functions, including installation and working principles. 3. Learn basic and advanced usage through examples. 4. Understand debugging techniques and performance optimization suggestions.

WordPress is a Content Management System (CMS). It provides content management, user management, themes and plug-in capabilities to support the creation and management of website content. Its working principle includes database management, template systems and plug-in architecture, suitable for a variety of needs from blogs to corporate websites.

WordPressisgoodforvirtuallyanywebprojectduetoitsversatilityasaCMS.Itexcelsin:1)user-friendliness,allowingeasywebsitesetup;2)flexibilityandcustomizationwithnumerousthemesandplugins;3)SEOoptimization;and4)strongcommunitysupport,thoughusersmustmanageper

Wix is suitable for users who have no programming experience, and WordPress is suitable for users who want more control and expansion capabilities. 1) Wix provides drag-and-drop editors and rich templates, making it easy to quickly build a website. 2) As an open source CMS, WordPress has a huge community and plug-in ecosystem, supporting in-depth customization and expansion.

WordPress itself is free, but it costs extra to use: 1. WordPress.com offers a package ranging from free to paid, with prices ranging from a few dollars per month to dozens of dollars; 2. WordPress.org requires purchasing a domain name (10-20 US dollars per year) and hosting services (5-50 US dollars per month); 3. Most plug-ins and themes are free, and the paid price ranges from tens to hundreds of dollars; by choosing the right hosting service, using plug-ins and themes reasonably, and regularly maintaining and optimizing, the cost of WordPress can be effectively controlled and optimized.

The core version of WordPress is free, but other fees may be incurred during use. 1. Domain names and hosting services require payment. 2. Advanced themes and plug-ins may be charged. 3. Professional services and advanced features may be charged.

WordPress is easy for beginners to get started. 1. After logging into the background, the user interface is intuitive and the simple dashboard provides all the necessary function links. 2. Basic operations include creating and editing content. The WYSIWYG editor simplifies content creation. 3. Beginners can expand website functions through plug-ins and themes, and the learning curve exists but can be mastered through practice.

People choose to use WordPress because of its power and flexibility. 1) WordPress is an open source CMS with strong ease of use and scalability, suitable for various website needs. 2) It has rich themes and plugins, a huge ecosystem and strong community support. 3) The working principle of WordPress is based on themes, plug-ins and core functions, and uses PHP and MySQL to process data, and supports performance optimization.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version
Chinese version, very easy to use