【问题标题】:Show only author comment on them wordpress dashboard仅在他们的 wordpress 仪表板上显示作者评论
【发布时间】:2011-12-18 09:31:10
【问题描述】:

我从这里的某个地方得到了这段代码,只在仪表板中显示作者的评论。但它甚至没有在作者仪表板上显示任何单个评论或作者帖子。

请帮我改正。

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; }; // Ensure that editors and admins can moderate all comments if(!current_user_can('edit_others_posts')) { add_filter('comments_clauses', 'my_plugin_get_comment_list_by_user'); }

【问题讨论】:

    标签: wordpress comments


    【解决方案1】:

    通过一些自定义来使用它:

    <?php
      $my_id = 7;
      $comment_id_7 = get_comment( $my_id, ARRAY_A );
      $name = $comment_id_7['comment_author'];
    ?> 
    

    也用这个:

    <div class="commentlist"><?php wp_list_comments(array('style' => 'div')); ?></div>
    

    【讨论】:

    • 可能是我的错误,我没有发布完整的代码。这是完整的代码。我正在寻找仪表板评论部分,而不是前端。此代码用于显示作者在仪表板评论部分的发表评论。所以作者只能看到他/她的帖子评论,也可以进行审核。但是,使用下面的代码,即使作者自己发表评论,它也会消失所有 cmets。
    • 这是我正在使用的代码...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; }; // Ensure that editors and admins can moderate all comments if(!current_user_can('edit_others_posts')) { add_filter('comments_clauses', 'my_plugin_get_comment_list_by_user'); }
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-09-30
    • 2023-03-13
    • 1970-01-01
    • 2011-09-06
    • 2015-07-26
    • 2020-12-11
    • 2012-06-16
    相关资源
    最近更新 更多