A lot of friends may find that there is a lot of English rubbish content, the following given a function
The code is as follows |
Copy Code |
<?php function Scp_comment_post ($incoming _comment) { $pattern = '/[one-?] /U '; Ban all comments in English if (!preg_match ($pattern, $incoming _comment[' comment_content ')) { Wp_die ("Your should type some Chinese word (like" hello ") in your comment to pass the Spam-check, for your patience! Your comments must contain Chinese characters! "); } Return ($incoming _comment); } |
The following code forbids the comment to include <a casually href= "or rel=" nofollow "or http://, you can also modify according to your own needs:
code is as follows |
copy code |
function Lianyue_comment_post ($incoming _comment) { $http = '/[href= |rel= ' nofollow ' |http://|</a>]/u '; if (Preg_match ($http, $incoming _comment[' comment_content ')) { Wp_die ("The Devil's Machine!"); } Return ($incoming _comment); } add_filter (' preprocess_comment ', ' Lianyue_c Omment_post '); |