Skip to:
Content
Pages
Categories
Search
Top
Bottom

Replies Created & Subscribed Forums


  • quigley05
    Participant

    @quigley05

    I am having issues placing a current user’s ‘Replies Created’ and ‘Subscribed Forums’ within their unique templates. See below.

    ‘Replies Created’ (login testuser / test1234)
    https://obeii.com/discussions-replies-created/
    Code seems to just want to display all replies instead of the specific users. How can this be corrected to be filtered to that specific user?

    <?php global $current_user; get_currentuserinfo(); $uid = bbp_get_current_user_id(); ?>
    <?php if ( bbp_get_user_replies_created( $uid ) ) : ?>
        <?php bbp_get_template_part( 'pagination', 'replies' ); ?>
        <?php bbp_get_template_part( 'loop', 'replies' ); ?>
        <?php bbp_get_template_part( 'pagination', 'replies' ); ?>
    <?php else : ?>
        <p><?php _e( 'You have not replied to any topics.', 'bbpress' ); ?></p>
    <?php endif; ?>	

    ‘Subscribed Forums’ (login testuser / test1234)
    https://obeii.com/discussions-subscriptions/
    It works fine for ‘Subscribed Topics’ below the item, however ‘Subscribed Forums’ comes up empty with no results. Any clue on why that is?

    <h2>Subscribed Forums</h2>				
    <?php global $current_user; get_currentuserinfo(); $uid = bbp_get_current_user_id(); ?>
    <?php if ( bbp_get_user_forum_subscriptions( $uid ) ) : ?>
        <?php bbp_get_template_part( 'pagination', 'forums' ); ?>
        <?php bbp_get_template_part( 'loop', 'forums' ); ?>
        <?php bbp_get_template_part( 'pagination', 'forums' ); ?>
    <?php else : ?>
        <p><?php _e( 'You are not currently subscribed to any forums.', 'bbpress' ); ?></p>
    <?php endif; ?>
Viewing 7 replies - 1 through 7 (of 7 total)

  • quigley05
    Participant

    @quigley05

    Any ideas? I keep scratching my head on this one. The code couldn’t be more clear to pull all data from the current user but it seems to ignore it..

    Any help at all would be greatly appreciated. Thanks!


    Robin W
    Moderator

    @robin-w

    untested but try

    <?php add_filter ('bbp_before_has_replies_parse_args' , 'rew_filter_for_user' ) ; ?>
        <?php bbp_get_template_part( 'pagination', 'replies' ); ?>
        <?php bbp_get_template_part( 'loop', 'replies' ); ?>
        <?php bbp_get_template_part( 'pagination', 'replies' ); ?>

    and in your functions file put

    function rew_filter_for_user ($args) {
    //not sure if the next two lines are needed, so have commented out
    //global $current_user;
    //get_currentuserinfo();
    $uid = bbp_get_current_user_id();
    $args[‘author’] => $uid ;
    return $args

    }

    loop-replies from memory has the ‘no relies’ part in it, so you shouldn’t need the ‘if’ statement
    I’m really pushed at the moment hence no time to test, but if it doesn’t work come back, and if I get time I’ll load it to my test site and debug


    quigley05
    Participant

    @quigley05

    Hi Robin,

    Thanks for the quick response. Unfortunately this function caused errors for me and ultimately caused the website to hang so I reverted. Let me know how I can better help you troubleshoot this with me.

    Thanks again!


    Robin W
    Moderator

    @robin-w

    ok, quick debug of the function, so this won’t error (and will hopefully work!)

    function rew_filter_for_user ($args) {
     //not sure if the next two lines are needed, so have commented out
     //global $current_user;
     //get_currentuserinfo();
     $uid = bbp_get_current_user_id();
     $args[‘author’] = $uid ;
     return $args ;
    }
    

    quigley05
    Participant

    @quigley05

    Hi Robin,

    I’ve placed the following code into my page template:

    <?php add_filter ('bbp_before_has_replies_parse_args' , 'rew_filter_for_user' ) ; ?>
        <?php bbp_get_template_part( 'pagination', 'replies' ); ?>
        <?php bbp_get_template_part( 'loop', 'replies' ); ?>
        <?php bbp_get_template_part( 'pagination', 'replies' ); ?>

    I also placed the revised code into my theme functions:

    function rew_filter_for_user ($args) {
     //not sure if the next two lines are needed, so have commented out
     //global $current_user;
     //get_currentuserinfo();
     $uid = bbp_get_current_user_id();
     $args[‘author’] = $uid ;
     return $args ;
    }

    However, doing this results in a blank page for the user.


    Robin W
    Moderator

    @robin-w

    can you post the entire template for me please, and tell me which template it is replacing


    quigley05
    Participant

    @quigley05

    Hi Robin,

    The ‘Replies Created’ template is replacing the one originally within the buddypress profile section.
    (https://obeii.com/discussions-replies-created/) (testuser / test1234)

    <?php
    /*
    Template Name: Discussions Replies Created
    */
    get_header();
    ?>
    
    <div class="sub-nav-container">
    	<div class="sub-nav-pagetitle">
    		<h1><?php the_title(); ?></h1>
    	</div>
    	<div class="sub-nav-about-menu">
    		<?php wp_nav_menu( array( 'theme_location' => 'sub-nav-discuss-menu', 'sort_column' => 'menu_order', 'container' => 'ul', 'menu_id' => 'sub-nav-discuss-menu', 'fallback_cb' => 'null', 'walker' => new Ghostpool_Custom_Menu ) ); ?>
    	</div>
    	<div class="sub-nav-extramenu">
    	</div>
    </div>
    
    <div id="gp-content-wrapper" class="gp-container">
    
    	<?php do_action( 'ghostpool_begin_content_wrapper' ); ?>
    			
    	<div id="gp-inner-container">
    		
    		<div id="gp-content">
    
    			<div class="gp-entry-content">
    				
    				
    <div id="bbpress-forums">
    	<?php do_action( 'bbp_template_before_user_replies' ); ?>
    
    	<div id="bbp-user-replies-created" class="bbp-user-replies-created">
    		<div class="bbp-user-section">
    
    <?php global $current_user; get_currentuserinfo(); $uid = bbp_get_current_user_id(); ?>
    <?php if ( bbp_get_user_replies_created( $user_id = bp_loggedin_user_id() ) ) : ?>
        <?php bbp_get_template_part( 'pagination', 'replies' ); ?>
        <?php bbp_get_template_part( 'loop', 'replies' ); ?>
        <?php bbp_get_template_part( 'pagination', 'replies' ); ?>
    <?php else : ?>
        <p><?php _e( 'You have not replied to any topics.', 'bbpress' ); ?></p>
    <?php endif; ?>	
    
    		</div>
    	</div>
    </div>				
    				
    			</div>
    			
    		</div>
    			
    		<?php get_sidebar( 'left' ); ?>
    
    		<?php get_sidebar( 'right' ); ?>
    
    	</div>
    	
    	<?php do_action( 'ghostpool_end_content_wrapper' ); ?>
    				
    	<div class="gp-clear"></div>
    	
    </div>
    
    <?php get_footer(); ?>

    The ‘Subscribed Forums’ template is also replacing the one originally within the buddypress profile section. It also contains ‘Subscribed Topics’ using similar code and that sections works as expected.
    (https://obeii.com/discussions-subscriptions/) (testuser / test1234)

    <?php
    /*
    Template Name: Discussions Subscriptions
    */
    get_header();
    ?>
    
    <div class="sub-nav-container">
    	<div class="sub-nav-pagetitle">
    		<h1><?php the_title(); ?></h1>
    	</div>
    	<div class="sub-nav-about-menu">
    		<?php wp_nav_menu( array( 'theme_location' => 'sub-nav-discuss-menu', 'sort_column' => 'menu_order', 'container' => 'ul', 'menu_id' => 'sub-nav-discuss-menu', 'fallback_cb' => 'null', 'walker' => new Ghostpool_Custom_Menu ) ); ?>
    	</div>
    	<div class="sub-nav-extramenu">
    	</div>
    </div>
    
    <div id="gp-content-wrapper" class="gp-container">
    
    	<?php do_action( 'ghostpool_begin_content_wrapper' ); ?>
    			
    	<div id="gp-inner-container">
    		
    		<div id="gp-content">
    
    			<div class="gp-entry-content">
    				
    <div id="bbpress-forums">				
    <div id="bbp-user-subscriptions" class="bbp-user-subscriptions">				
    				
    <h2>Subscribed Forums</h2>				
    <?php global $current_user; get_currentuserinfo(); $uid = bbp_get_current_user_id(); ?>
    <?php if ( bbp_get_user_forum_subscriptions( $uid ) ) : ?>
        <?php bbp_get_template_part( 'pagination', 'forums' ); ?>
        <?php bbp_get_template_part( 'loop', 'forums' ); ?>
        <?php bbp_get_template_part( 'pagination', 'forums' ); ?>
    <?php else : ?>
        <p><?php _e( 'You are not currently subscribed to any forums.', 'bbpress' ); ?></p>
    <?php endif; ?>
    				
    <br><br>	
    				
    <h2>Subscribed Topics</h2>				
    <?php global $current_user; get_currentuserinfo(); $uid = bbp_get_current_user_id(); ?>
    <?php if ( bbp_get_user_topic_subscriptions( $uid ) ) : ?>
        <?php bbp_get_template_part( 'pagination', 'topics' ); ?>
        <?php bbp_get_template_part( 'loop', 'topics' ); ?>
        <?php bbp_get_template_part( 'pagination', 'topics' ); ?>
    <?php else : ?>
        <p><?php _e( 'You are not currently subscribed to any topics.', 'bbpress' ); ?></p>
    <?php endif; ?>
    
    </div>
    </div>				
    				
    				
    				
    			</div>
    			
    		</div>
    			
    		<?php get_sidebar( 'left' ); ?>
    
    		<?php get_sidebar( 'right' ); ?>
    
    	</div>
    	
    	<?php do_action( 'ghostpool_end_content_wrapper' ); ?>
    				
    	<div class="gp-clear"></div>
    	
    </div>
    
    <?php get_footer(); ?>
Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Skip to toolbar