0

我正在使用 wordpress 开发一个网站,该网站在照片库和一些教程视频页面中有一个评论区。我如何限制未登录的用户发表评论和访问视频页面。直到我有很多谷歌但没有得到任何与我的问题相关的解决方案。我已经搜索了很多插件,但没有用,注册时我使用的是 pie register 插件,我的 word-press 主题是抛物线。我尝试对主题文件夹中的 comment.php 文件进行一些更改:

<?php
    /**
     * The template for displaying Comments.
     *
     * The area of the page that contains both current comments
     * and the comment form. The actual display of comments is
     * handled by a callback to tc_comment_callback()
     *
     * @package Customizr
     * @since Customizr 1.0
     */

    /*
     * If the current post is protected by a password and
     * the visitor has not yet entered the password we will
     * return early without loading the comments.
     */
     if ( have_comments() )
         echo apply_filters( 'tc_comment_separator', '<hr class="featurette-divider '. current_filter() .'">' );
?>

     <div id="comments" class="<?php echo apply_filters( 'tc_comments_wrapper_class' , 'comments-area' ) ?>" >
<?php 
     if( is_user_logged_in() )
     {
         comment_form( array( 'title_reply' => __( 'Leave a Comment' , 'customizr' ) ) );
         if ( have_comments() )
         do_action ( '__comment' );
      }
?>
    </div><!-- #comments .comments-area -->
4

1 回答 1

0

简单地放一个!之前is_user_logged_in()

例如:

if( !is_user_logged_in() ) {
    // Content shown for non-users
}

if( is_user_logged_in() ) {
    // Content shown for authorized users
}
于 2014-09-30T13:15:56.730 回答