Skip to content

Instantly share code, notes, and snippets.

@dillonhafer
Created August 18, 2013 03:03
Show Gist options
  • Save dillonhafer/6259707 to your computer and use it in GitHub Desktop.
Save dillonhafer/6259707 to your computer and use it in GitHub Desktop.
This simple script should be inserted into line 54 of wp-comments-post.php to block comments based on email addresses.
// Goes after this section below
$comment_author = ( isset($_POST['author']) ) ? trim(strip_tags($_POST['author'])) : null;
$comment_author_email = ( isset($_POST['email']) ) ? trim($_POST['email']) : null;
$comment_author_url = ( isset($_POST['url']) ) ? trim($_POST['url']) : null;
$comment_content = ( isset($_POST['comment']) ) ? trim($_POST['comment']) : null;
// WordPress Block Commenters by email
$black_list = array(
"guert84****@gmail.com",
"test@dillonhafer.com"
);
if (in_array($comment_author_email, $black_list)) {
$comment_author_email = null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment