WordPress Snippets at WPcustoms

Mark long author urls as spam

If a comments author website is longer than 50 letters the comment will automatically marked as spam. Long urls are an easy sign for backlink bots trying to get their links up.


/**
 * Snippet Name: Mark long author urls as spam
 * Snippet URL: http://www.wpcustoms.net/snippets/mark-long-author-urls-spam/
 */
  function wpc_url_spamcheck( $approved , $commentdata ) {
    return ( strlen( $commentdata['comment_author_url'] ) > 50 ) ? 'spam' : $approved;
  }

  add_filter( 'pre_comment_approved', 'wpc_url_spamcheck', 99, 2 );