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?
Check in your theme’s
comments.php
for thewp_list_comments()
function. In the Twenty Eleven theme, for example, uses a custom callback function which is in thefunctions.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:In wp-includes/admin-bar.php, add a “return;” statement at the start of wp_admin_bar_comments_menu so it looks like this: