Skip to:
Content
Pages
Categories
Search
Top
Bottom

Create a profile settings subnav


  • freya
    Participant

    @fannyonholidays

    Hello,
    I work on a Buddyboss setup. I created a profile subnav (like ‘edit profile’ and ‘change photo’).
    The only thing is I don’t know which template to load in my last line of code for the content to look like a settings page.

    Here is my working code:

    function buddyboss_custom_user_subtab() {
    
    	// Avoid fatal errors when plugin is not available.
    	if ( ! function_exists( 'bp_core_new_nav_item' ) ||
    		 ! function_exists( 'bp_loggedin_user_domain' ) ||
    		 empty( get_current_user_id() ) ) {
    
    		return;
    
    	  }
    
      	global $bp;
    
      	$args = array();
    
      	// Tab 1 arg.
      	$args[] = array(
    		'name'                => esc_html__( 'Link Social Accounts', 'default' ),
    		'slug'                => 'connect-socials',
    		'screen_function'     => 'connect_socials',
    		'position'            => 100,
    		'parent_url'          => bp_loggedin_user_domain() . 'profile/',
    		'parent_slug'         => $bp->profile->slug,
    	);
    
    	foreach ( $args as $arg ) {
    		bp_core_new_subnav_item( $arg );
    	}
    }
    
    add_action( 'bp_setup_nav', 'buddyboss_custom_user_subtab' );
    
    /* Display content of custom tab. */
    function connect_socials() {
    	add_action( 'bp_template_title', 'connect_socials_title' );
    	add_action( 'bp_template_content', 'connect_socials_content' );
    	bp_core_load_template( apply_filters( ????????????? ) );
    }
    
    /* Display content of custom tab. */
    function connect_socials_title() {
    	echo esc_html__( 'Custom Tab', 'default' );
    }

    Here is the output: https://ibb.co/58Y2WDy on the tabs part, but when I select the tab ‘Link Social Account’, the tempate isn’t the right one no matter what I try.

    Thank you for your help!

  • You must be logged in to reply to this topic.
Skip to toolbar