Automatically deleting WordPress comments using a theme

Let's say you want to automatically delete specific sorts of comments from your WordPress blog. For example, immediately trashing any comment that has a specific phrase "Elephant Juice" in it. You can do this by going to Settings -> Discussion → Disallowed Comment Keys. Or you can add something to your theme's functions.php file. Here's the code snippet: add_action( 'comment_post', 'check_comment_content', 10, 2 ); function check_comment_content( $comment_id, $comment_approved ) { $…
Continue reading →