📅  最后修改于: 2022-03-11 14:48:37.541000             🧑  作者: Mango
// 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');
}