Lego2012
12/13/2016 - 11:28 AM

Spam Comments with Very Long URL’s

Spam Comments with Very Long URL’s

<!-- https://twitter.com/chriscoyier/status/327840451832975360 -->

<!-- Super long URL's are a sure fire sign the comment is spammy. This will mark comments with URL's (as the author URL, not just in the text) longer than 50 characters as spam, otherwise leave their state the way it is. -->

<?php

  function rkv_url_spamcheck( $approved , $commentdata ) {
    return ( strlen( $commentdata['comment_author_url'] ) > 50 ) ? 'spam' : $approved;
  }

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

?>