Spam Block for Nick Momrik's Recent Comments plugin (5 posts)

  1. justkristin
    Posted 10 years ago #

    Disclaimer: As always, if this is a duplicate effort, please pardon.

    I added a few things to this plugin's SQL statement in order to get it to display only approved comments. (Its ver. 1.12 had been displaying even comments that had 'spam' in the comment_approved field.)
    I added "comment_approved" just before "post_title" in the initial SELECT statement, moved "AND post_status = 'publish' " down two rows to the beginning of the ORDER BY section, and prefixed it with ""WHERE comment_approved = '1'". It seems to have stopped all but approved comments from showing up.

    Actual code:

    function get_recent_comments($no_comments = 5, $comment_lenth = 5, $before = "
    <li>", $after = "</li>
    ", $show_pass_post = false, $comment_style = 0) {
    global $wpdb;
    $request = "SELECT ID, comment_ID, comment_content, comment_author, comment_approved, post_title FROM $wpdb->comments LEFT JOIN $wpdb->posts ON $wpdb->posts.ID=$wpdb->comments.comment_post_ID "; //AND post_status = "publish" ";
    if(!$show_pass_post) $request .= "AND post_password ="" ";
    $request .= "WHERE comment_approved = "1" AND post_status = "publish" ORDER BY comment_ID DESC LIMIT $no_comments";
    $comments = $wpdb->get_results($request);

  2. NuclearMoose
    Posted 10 years ago #

    Please post code on your own site and provide a link to it here. Thank you! :)

  3. Nick Momrik
    Posted 10 years ago #


    I overlooked that and just updated the plugins....time for a new update!

  4. Nick Momrik
    Posted 10 years ago #

    Whoops, actually that was built into 1.14 if I remember and the plugin is now at 1.15.


  5. justkristin
    Posted 10 years ago #

    Yeah, it was. Sorry. Shoulda checked first. :) Ah, well. It was good exercise for my remedial coding skills. :P Thanks for all you do!

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.