优选主流主机商
任何主机均需规范使用

如何在WordPress后台查看用户文章及关联评论

本文实例讲述了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’);

}

注:如果你的WordPress所使用的数据库前缀不是默认的 wp_,请将第 5 、6 行中的 wp_ 修改为你的WordPress站点的数据库前缀。

未经允许不得转载:搬瓦工中文网 » 如何在WordPress后台查看用户文章及关联评论