I absolutely hate SPAM in my comments. I fantasize sometimes about sneaking up on would-be spammers with an iron skillet just before they can hit send. Okay … assault is a bit excessive, so shy of committing a felony, how can we slow these spammers down? One way is to take away the HTML privilege from commenters. Add the following code to your functions.php:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | // This will occur when the comment is posted function plc_comment_post( $incoming_comment ) { // convert everything in a comment to display literally $incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']); // the one exception is single quotes, which cannot be #039; because WordPress marks it as spam $incoming_comment['comment_content'] = str_replace( "'", ''', $incoming_comment['comment_content'] ); return( $incoming_comment ); } // This will occur before a comment is displayed function plc_comment_display( $comment_to_display ) { // Put the single quotes back in $comment_to_display = str_replace( ''', "'", $comment_to_display ); return $comment_to_display; |

Leave a Reply