2007
04.01

Trackback Validator hack

Apart of Captcha!, to fight trackback SPAM I also use Trackback Validator, which works very well but has a little problem however: regardless the trackback is ham or spam, you always get it via email if “mail comments” feature is enabled in your WP panel. So you might end up with your mailbox flooded of spam trackbacks (even though they’re correctly filtered in your blog).

Due to this, I’ve made a little hack to fix this. So only valid trackbacks are mailed to you, not the SPAM ones.

Download it here.

Update: (2007-04-01) It seems I’m not the first one to do something like this. Although it uses another approach (hacking WP directly).

Share
  1. Thanks for the suggestion, but when I make that change, I get email again.

    Like or Dislike: Thumb up 0 Thumb down 0

  2. Jon, to me it’s updating (at least with valid trackback / pingbacks).

    Try changing the line which reads:
    wp_set_comment_status($comment_ID, 'delete');

    And put:
    wp_set_comment_status($comment_ID, 'spam');
    instead.

    Like or Dislike: Thumb up 0 Thumb down 0

  3. I like this hack, but is there a way to eliminate the email while still allowing the “trackback_graph” to be updated?

    Like or Dislike: Thumb up 0 Thumb down 0

  4. Alex, here you are:
    [code lang=”php”]
    10a11
    >
    135c136,139
    < --- >
    > if ($tb_info[‘comment_type’] != ‘trackback’) // Ensure it’s a trackback
    > return $comment_ID;
    >
    141c145,146
    < $wpdb->query(“UPDATE $wpdb->comments SET comment_approved = ‘1’ WHERE comment_ID = ‘$comment_ID'”);

    > //$wpdb->query(“UPDATE $wpdb->comments SET comment_approved = ‘1’ WHERE comment_ID = ‘$comment_ID'”);
    > wp_set_comment_status($comment_ID, ‘approve’);
    143c148,150
    < $wpdb->query(“UPDATE $wpdb->comments SET comment_approved = ‘spam’ WHERE comment_ID = ‘$comment_ID'”);

    > //$wpdb->query(“UPDATE $wpdb->comments SET comment_approved = ‘spam’ WHERE comment_ID = ‘$comment_ID'”);
    > // wp_set_comment_status($comment_ID, ‘spam’);
    > wp_set_comment_status($comment_ID, ‘delete’);
    145c152
    < update_comment_count($tb_info['comment_post_ID']); --- > //update_comment_count($tb_info[‘comment_post_ID’]);
    147c154
    < --- >
    297c304
    < add_action('trackback_post', 'tb_check',1,1); --- > add_action(‘comment_post’, ‘tb_check’);
    [/code]

    Like or Dislike: Thumb up 0 Thumb down 0

  5. So I just saw this link in my latest activity list. Could you post a diff from the original source? I’d love to see what exactly you did to get it to work without modifying WP itself.

    Like or Dislike: Thumb up 0 Thumb down 0