不管什么需求都可能存在的,就比如WordPress用户只能查看自己的文章与评论,这个需求就是比较少,但是也有很多人希望有的,那么我们该怎么做呢?
把下面的代码复制到主题下面的Functions.php中:
/*只能查看自己的文章评论*/
function wpdx_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', 'wpdx_get_comment_list_by_user');
}
温馨提示:本文最后更新于
2024-07-13 08:57:19
,某些文章具有时效性,若有错误或已失效,请 联系我们 反馈。👋 感谢您的观看!
© 版权声明
THE END