Skip to:
Content
Pages
Categories
Search
Top
Bottom

Show Member Loop within Custom Profile Tab


  • hornets2002
    Participant

    @hornets2002

    Hi, I am trying to add a custom nav link titled “sub-members” to buddypress profiles that shows a list of members who inherit membership to my client’s services through the parent member. I have successfully added the custom nav link to the profile by inserting some code into bp-custom.php and I have successfully called the contents of a members loop template into the page (I will add filtering for the members loop after initial functionality is in place.)

    Here is my code below:

    <?php
    function add_communications_tabs() {
    	global $bp;
    
    		if (xprofile_get_field_data('Sub-Members') == "Yes")  :
    		bp_core_new_nav_item( array(
    		'name'                  => 'Sub-Members',
    		'slug'                  => 'submembers',
    		'parent_url'            => $bp->displayed_user->domain,
    		'parent_slug'           => $bp->profile->slug,
    		'screen_function'       => 'submembers_screen',		
    		'position'              => 100,
    		'default_subnav_slug'   => 'submembers'
    	) );
    	endif;
    }
    
    add_action( 'bp_setup_nav', 'add_communications_tabs', 100 );
    
    function submembers_screen() {
        add_action( 'bp_template_content', 'submembers_screen_content' );
        bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
    }
    
    function submembers_screen_title() {
      	echo $_POST[bp_displayed_user_id()];
    	echo 'Sub-members of '.bp_get_displayed_user_fullname().'<br/>';
    }
    
    function submembers_screen_content() { 
    get_template_part( '\buddypress\members\members', 'loop' ); 
    }
    
    ?>

    Here is my problem:

    Pagination and any other function using ajax seems to break when the members loop is placed here.

    It seems that while ajax work fine for the members loop when placed on a normal page outside the profile–and I should also mention ajax works fine for built-in Buddypress profile functions like activity stream posting–the same cannot be said for my members loop or any other content I test on the custom-made ‘sub-members’ page that requires ajax functionality. For instance, when I try to click on a link within the pagination on the member loop within the ‘sub-members’ page, the link is correct (loads the next page in the loop if it were to be opened in a new tab), but nothing happens when it is clicked.

    Steps I tried to pinpoint the issue:
    – Disabled all plugins besides Buddypress for potential conflicts
    – Inserted other ajax content independent of Buddypress onto the ‘sub-members’ page (this content failed too)
    – Tested the Members Loop within existing profile page templates to see if it had to do with inserting it onto a custom Buddypress page (loaded it on the “Activity” page and the ajax didn’t work for this either)
    – Tried to enqueue ajax.php and other relevant scripts despite the fact that in the <head> section, it seems they are being called correctly and working for other built-in ajax calls.

    I have spent many hours trying to figure this out and I would greatly appreciate any help as I am truly stumped and not very knowledgeable about ajax. Thank you

Viewing 1 replies (of 1 total)

  • hornets2002
    Participant

    @hornets2002

    Quick note: the “add_communications_tabs()” is referring to additional code I deleted for clarity, as I also added a couple additional nav links dealing with communication logging between the organization and the specified member.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar