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测试数据ment_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后台显示相关用户文章相关联的评论 - W的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did8644