Created
December 27, 2014 10:16
-
-
Save palpalani/5396436835cf03f2d827 to your computer and use it in GitHub Desktop.
WordPress - Display comments in admin to authors own posts only
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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