Skip to content

Instantly share code, notes, and snippets.

@palpalani
Created December 27, 2014 10:16
Show Gist options
  • Save palpalani/5396436835cf03f2d827 to your computer and use it in GitHub Desktop.
Save palpalani/5396436835cf03f2d827 to your computer and use it in GitHub Desktop.
WordPress - Display comments in admin to authors own posts only
<?php
//Display comments in admin to authors own posts only
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');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment