• I’m developing a Captcha anti-spam plugin, but don’t want to do what most do, which is let the comment post, and then delete it from the database. Therefore, it acts at the preprocess_comment level.

    However, I need a way to identify pingbacks and trackbacks at the preprocess_comment level, since Captcha effectively blocks them all (and I’d want to allow them through). What variable(s) can identify pingbacks and trackbacks *before* they are posted?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Both pingbacks and trackbacks get posted via wp_new_comment(), and so the preprocess_comment hook will get them that way. If you look at the comment_type part of the incoming array, you’ll see when it’s a pingback/trackback.

    function your_preprocess($incoming_comment)
    {
    if ($incoming_comment['comment_type'] == 'pingback' ||
    $incoming_comment['comment_type'] == 'trackback') {
    // allow it or something
    }
    }
    add_filter('preprocess_comment','your_preprocess');

    Not that I support Captcha’s, BTW. They don’t work.

    Thread Starter Peter

    (@pkthree)

    Thanks, this was great. I was struggling for the longest time using code similar to what you just posted, but as it turns out I mistakenly had the called up the variable $incoming_comment with my globals. Silly, silly me.

    brilliant!
    that solved my problem for identifying a trackback on the preprocess_comment filter

    thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Identifying pingbacks and trackbacks at the preprocess_comment level’ is closed to new replies.