WordPress.org

Ready to get started?Download WordPress

Forums

User Specific Content
[resolved] How to also enable comments to be hidden for not selected users (4 posts)

  1. GreenDiablo
    Member
    Posted 3 years ago #

    Is there a way to not just hide the post content but also the comments of a post selected for user specific content?

    Urgent, please let me know if that's possible and how to achieve that.

    Thanks so much!
    -Sonja

  2. Bainternet
    Member
    Plugin Author

    Posted 3 years ago #

    @Sonja, the plugin is called User Specific Content and that is way its only for content, as for comments, you can filter and control who sees them with the built-in WordPress Plugins.

  3. GreenDiablo
    Member
    Posted 3 years ago #

    Thanks @Bainternet, I'll check it out!

  4. Bainternet
    Member
    Plugin Author

    Posted 2 years ago #

    UPDATE
    i keep getting the same questions for people so here is a quick solution, the idea is to create a new instance of the plugin and use its filter function something like:

    <?php
    //get comments and comment form as a var
    global $post;
    $comments = get_comments('post_id='.$post->ID);
    $com = '';
    foreach($comments as $comment) :
        $com .= '<div class="com_container">
            <div class="com_author">'.$comment->comment_author . '</div>
            <div class="com_content">' . $comment->comment_content.'</div>
            </div>';
    endforeach;
    ob_start();
    comment_form();
    $com .= '<div class="com_form">'.ob_get_contents().'</div>';
    ob_end_clean();    
    
    //here you have two options, either to set the shortcode manually for each page:
    //$com = '[O_U user_id="1,2,3" blocked_meassage="comments are closed for everyone!"]'. $com .'[/O_U]';
    //then run it by the shortcode
    //echo do_shortcode($com);
    
    //or you can create a new instance of the plugin class and let it use the same sattings as the content on that page:
    $limit_C = new bainternet_U_S_C();
    echo $limit_C->User_specific_content_filter($com);
    ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic