Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

display only user contributor comments wordpress

// Add to functions.php
function authorize_comments_for_current_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', 'authorize_comments_for_current_user');
}
 
PREVIOUS NEXT
Tagged: #display #user #contributor #comments #wordpress
ADD COMMENT
Topic
Name
2+2 =