как я могу запретить незарегистрированным пользователям доступ к определенному контенту или страницам в wordpress

Я разрабатываю веб-сайт с wordpress, в котором есть область комментариев в фотогалерее и страница с обучающими видеороликами. как я могу запретить незарегистрированным пользователям оставлять комментарии и переходить на страницу видео. До сих пор у меня много Google, но я не нашел решения, связанного с моей проблемой. Я уже перерыл множество плагинов, но это было бесполезно. Для регистрации я использую плагин 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 -->

person Danish Jamil    schedule 30.09.2014    source источник
comment
проверьте это здесь codex.wordpress.org/Function_Reference/is_user_logged_in   -  person Jothi Kannan    schedule 30.09.2014


Ответы (1)


Просто поставьте ! перед is_user_logged_in().

Например:

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

if( is_user_logged_in() ) {
    // Content shown for authorized users
}
person Ole Haugset    schedule 30.09.2014