Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This is a strange one. I host a website that is primarily for children. All posts are moderated. Users are required to enter a user name and location (State), but are not required to be registered and logged in to make a comment. Some users have started using a common user name, allowing them to see one another's posts while the posts are awaiting moderation. This allows them to use the posts awaiting moderation like an unmoderated chat room, until the moderator gets to the comments.

I would like to filter the comments on the posts so that only approved comments are shown, regardless of whether the user just entered a comment that is awaiting moderation.

I have looked in the wp-includes/comments.php, and in the wp-includes/post.php but haven't been able to find where to limit the comments that are seen on the posts.

Can anyone direct me further?

share|improve this question
    
+1 for ingenious children. The place where you'll need to edit which comments get displayed would be in your theme's comments.php. Please post your theme name (or the code from that file if it's custom). –  stealthyninja Oct 18 '12 at 18:04
    
@stealthyninja - Thanks for your help. The Theme is custom. I am not sure from which Theme is was originally modified. The code is below: –  VWTom Oct 18 '12 at 18:32
    
Having issues putting the code from the comments.php up. I will see what I can find based upon your answer below. Thank you for your help. –  VWTom Oct 18 '12 at 18:51
    
You could put it on pastebin. –  stealthyninja Oct 18 '12 at 18:53
add comment

2 Answers

up vote 0 down vote accepted

Check in your theme's comments.php for the wp_list_comments() function. In the Twenty Eleven theme, for example, uses a custom callback function which is in the functions.php file and outputs the template for comments.

Within this comments template, you can then use wp_get_comment_status() and only display a comment if it was approved. Example from the Codex:

$status = wp_get_comment_status( $comment_id );

if ( $status == "approved" ) {
    // the rest of the comment loop
}
share|improve this answer
    
Thanks @stealthyninja! You pointed me in the correct direction. I found out my Theme was a modification of the Kubrick Theme, so this is what I did: –  VWTom Oct 18 '12 at 21:49
1  
<?php if ($comment->comment_approved == '1') : ?> // the rest of the comment loop –  VWTom Oct 18 '12 at 21:52
add comment

In wp-includes/admin-bar.php, add a "return;" statement at the start of wp_admin_bar_comments_menu so it looks like this:

function wp_admin_bar_comments_menu( $wp_admin_bar ) {
        return; /* Added by don smith */;
        if ( !current_user_can('edit_posts') )
                return;
 .....
}
share|improve this answer
    
Editing WordPress core files (hacking the core) is not recommended. –  Ben Miller Aug 28 '13 at 15:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.