Home>Article>CMS Tutorial> How to prohibit WordPress comments from specifying content in English
How to disable comments in WordPress that contain specific content in English?
The example in this article describes how WordPress prohibits comments on specified content in English. Share it with everyone for your reference. The specific analysis is as follows:
Recommendation: "wordpress tutorial"
The first thing to filter out in WordPress comments is all-English spam. This is simple. We only need to check whether the Chinese characters are included. Sometimes we want some sensitive words not to be submitted. All we need is a simple filtering function.
Many friends may find that there is a lot of English garbage discussion content , here is a function, the code is as follows:
The code is as follows:
The following code prohibits comments from containing
The code is as follows:
function lianyue_comment_post( $incoming_comment ) { $http = '/[href="//m.sbmmt.com/m/faq/|rel="nofollow"|http://|]/u'; if(preg_match($http, $incoming_comment['comment_content'])) { wp_die( "万恶的发贴机!" ); } return( $incoming_comment ); } add_filter('preprocess_comment', 'lianyue_comment_post');
I hope this article will be helpful to everyone’s WordPress website building.
The above is the detailed content of How to prohibit WordPress comments from specifying content in English. For more information, please follow other related articles on the PHP Chinese website!