serks (@serks)

Forum Replies Created

Viewing 1 replies (of 1 total)

  • serks
    Participant

    @serks

    Thanks for response Stephan,
    I actually managed to do this by using some code in loop-search.php and I used the same code in loop-replies.php…heres the code that does it…

    
    <?php if(get_post_type() == 'reply'):?>
    
           <?php // CHECK IF THIS REPLY IS UNDER MEMBERS ONLY FORUM.
           $parent = array_reverse(get_post_ancestors($post->ID)); // get an array of all the parent pages in order from most distant to closest.
           $first_parent = get_page($parent[0]); //get the first page in the array, which is the most distant parent
           $int = apply_filters('the_ID', $first_parent->ID); //filter the $first_parent to get only the wordpress page/post ID, which is an integer like 49 or 565. store it as a variable $int
           ?>
    		
            <?php if($int == 48) :?>
    	        <?php // DISPLAY A MESSAGE SAYING THE REPLY IS HIDDEN ?>
    	        <?php if(!user_subscribed()):?>
    		        <?php //bbp_get_template_part( 'loop', 'search-reply-membersonly'); ?>
    		        <div class="hidden-forum-comment">This comment is only visible to subscribers. <a href="/join">Click here to subscribe.</a></div>
    	        <?php endif;?>
            <?php else :?>
                    <?php bbp_get_template_part( 'loop', 'search-reply'); ?>
            <?php endif ;?>
    
    <?php elseif(get_post_type() == 'forum'): ?>
    	<?php bbp_get_template_part( 'loop', 'search-forum'); ?>
    <?php elseif(get_post_type() == 'topic'): ?>	
    	<?php bbp_get_template_part( 'loop', 'search-topic'); ?>
    <?php endif;?>
    
    

    Hope i’ve pasted that correctly.
    48 is the ID of the Members Only Forum.
    !user_subscribed() is one of my own functions to check if a user is subscribed to a product with DAP (Digital Access Pass).

    If anyone needs more help with this just ask. Be happy to help.

Viewing 1 replies (of 1 total)