我一直在寻找登录用户可以看到自己帖子的代码,但我成功地制作了简单的函数,我们可以使用相同的函数,函数片段必须包含在函数中。正在使用的主题文件夹中的php文件
function my_plugin_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\', \'my_plugin_get_comment_list_by_user\');
}
谢谢NIkhil Joshi