Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] How to create a new tab in members component in BP 1.7 beta?


  • neo64
    Participant

    @neo64

    I´m trying to create a new tab in BP 1.7 members menu with this code:

    
    function my_bp_nav_adder() {
    
    	bp_core_new_nav_item(
    	
    	array(
    	
    	'name' => __( 'Media Privacy','bp-media-privacy' ),
    	
    	'slug' => 'cuenta',
    	
    	'position' => 75,
    	
    	'show_for_displayed_user' => true,
    	
    	'screen_function' => 'bp_media_privacy_link',
    	
    	'item_css_id' => 'bp-media-privacy'
    	
    	)
    	);
    
    }
    
    function bp_media_privacy_link () {
    
    add_action( 'bp_template_title', 'my_media_privacy_title' );
    
    add_action( 'bp_template_content', 'my_media_privacy_content' );
    
    bp_core_load_template( apply_filters( 'bp_core_template_plugin', '/members/single/plugins' ) );
    
    }
    
    function my_media_privacy_title() {
    
    echo 'My Page Title';
    
    }
    
    function my_media_privacy_content() {
    
    echo 'Add the content loop here';
    
    }
    
    add_action( 'bp_setup_nav', 'my_bp_nav_adder', 100 );
    

    The code create a new tab, but when I click the tab buddypress redirect me to the members loop, and not create the content for the new tab.

    Any suggestions? thanks

Viewing 5 replies - 1 through 5 (of 5 total)

  • modemlooper
    Moderator

    @modemlooper

    function  my_bp_nav_adder() {
    
    global $bp;
    
    bp_core_new_nav_item( array(
    
    'name' => __( 'Media Privacy','bp-media-privacy' ),
    
    'slug' => 'cuenta',
    
    'parent_slug' => $bp->displayed_user->domain,
    
    'parent_url' => $bp->displayed_user->domain,
    
    'screen_function' => 'bp_media_privacy_link,
    
    'position' => 75,
    
    'user_has_access' => bp_is_my_profile()
    
    ) );
    
    }
    
    add_action( 'bp_setup_nav', ' my_bp_nav_adder' );

     


    neo64
    Participant

    @neo64

    Thanks, but I try your code and the problem is the same, when I click into the tab link it redirects me to the correct url: /members/user/cuenta/ but this page show the member loop list, and not a tab with my custom content.


    modemlooper
    Moderator

    @modemlooper

    EDIT: just noticed I was not on 1.7

    There seems to be a problem with this.


    modemlooper
    Moderator

    @modemlooper

    Ok, thanks to @boone for troubleshooting, if it’s a tab it needs to have a default sub tab specified.

    function my_bp_nav_adder() {
    
    global $bp;
    
    bp_core_new_nav_item( array(
    
    'name' => __( 'Media Privacy','bp-media-privacy' ),
    
    'slug' => 'cuenta',
    
    'default_subnav_slug' => 'cuenta',
    
    'screen_function' => 'bp_media_privacy_link,
    
    'position' => 75,
    
    'user_has_access' => bp_is_my_profile()
    
    ) );
    
    }
    
    add_action( 'bp_setup_nav', ' my_bp_nav_adder' );

    neo64
    Participant

    @neo64

    Thank you, this code is perfect.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] How to create a new tab in members component in BP 1.7 beta?’ is closed to new replies.
Skip to toolbar