updated   : April 22, 2013
we now have 608 snippets

Display comments in admin to authors own posts only

wordpress snippet

Only show the comments to the authors own posts within the wordpress admin, hide all other comments. This is a great little snippet if you want authors to look after their own comments. Just add this snippet to the functions.php of your wordpress theme and you are ready to go.

snippet :  PHPcopy
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');
}
source →
  • http://www.leachcreative.com/ Andrew Leach

    This is pretty cool, thanks for sharing.

    • http://wpsnipp.com Kevin Chard

      No problem Andrew,

  • http://www.iblognet.com/ Sahil

    Ah! :) Thanks .. another great snippet! Very much similar to author post restriction!
    I’m loving your site!!! :)

    • http://wpsnipp.com Kevin Chard

      Glad to hear it, lots of stuff on the way :)

  • http://twitter.com/maxisanchez Maximiliano Sánchez

    Hey, thanks for your amazing site!

    • http://wpsnipp.com Kevin Chard

      No problem enjoy the wordpress code snippets

  • http://www.facebook.com/behroozkarami1 Behrooz Karami

    Where do I copy this code ?

    • http://wpsnipp.com Kevin Chard

      Sorry about that, I update the post. Just add this snippet to the functions.php of your wordpress theme.

  • Pingback: How to Filter Comments in the WordPress Admin for Quicker Moderation - WPMU.org

  • Dominic

    If the database preifx is something else than wp_ this function won’t work. You should replace wp_ by “.$wpdb->base_prefix.” in join and where clause to fix it.

    • Dominic

      I meant database prefix

  • batman

    work in localhost but don’t work in host ???