WordPress.org

Support

Support » Plugins and Hacks » Spam Block for Nick Momrik’s Recent Comments plugin

Spam Block for Nick Momrik’s Recent Comments plugin

  • 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);

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Spam Block for Nick Momrik’s Recent Comments plugin’ is closed to new replies.
Skip to toolbar