How to Filter Comments in the WordPress Admin for Quicker Moderation

How to Filter Comments in the WordPress Admin for Quicker Moderation

When you have an active multi-author blog, it’s important for authors to be able to quickly moderate comments on the blogs they are publishing. You don’t want to build up a backlog of hundreds of unmoderated comments, because it can stall activity and discussion on your site.

Here’s a handy little snippet that will change how comments appear on the Dashboard >> Comments admin page. It filters the comments to display only those that appear on the author’s posts while hiding comments on blogs they didn’t write. This is very useful if you want authors to be responsible for the comments on their own blogs. It will help them to moderate those comments more efficiently, without having to dig through the sea of comments from other blogs on the site.

Add this to your theme’s functions.php file or, if you’re more of a purist, create your own little plugin for it:

function wps_get_comment_list_by_user($clauses) {
if (is_admin()) {
global $user_ID, $wpdb;
$clauses['join'] = ", wp_posts";
$clauses['where'] .= " AND wp_posts.post_author = ".$user_ID." AND wp_comments.comment_post_ID = wp_posts.ID";
};
return $clauses;
};
if(!current_user_can('edit_others_posts')) {
add_filter('comments_clauses', 'wps_get_comment_list_by_user');
}

Credit for this useful snippet goes to Kevin Chard of WPSNIPP.com.

FREE EBOOK
Your step-by-step roadmap to a profitable web dev business. From landing more clients to scaling like crazy.

By downloading this ebook I consent to occasionally receive emails from WPMU DEV.
We keep your email 100% private and do not spam.

FREE EBOOK
Plan, build, and launch your next WP site without a hitch. Our checklist makes the process easy and repeatable.

By downloading this ebook I consent to occasionally receive emails from WPMU DEV.
We keep your email 100% private and do not spam.

Once you’ve added this code you should start seeing the comments filtered for authors on your site. Admins and users who can edit_others_posts will see all of the comments from all blogs just as you would normally expect.

Comment moderation can eat up quite a bit of your time. This will help authors to moderate and reply to comments more efficiently because it makes it easy for your authors to get direct access to all of the comments applicable to the blogs they’ve written.

Tags: