This topic has 2 replies, 2 voices, and was last updated 10 years by erannou.

  • Author
  • #16670
     erannou
    Participant

    Hello everyone,

    I tried to add a custom tabs after the usual profile tabs, like this:
    ACTIVITY
    PROFILE
    NOTIFICATIONS
    MESSAGES
    FRIENDS
    GROUPS
    FORUMS
    MEDIA
    SETTINGS
    CUSTOM TAB

    I succesffully added it by following some tutorial with the bp_core_new_nav_item functions. The problem is to display a specific page when I click on it.

    On most of the other themes, we just add this kind of functions:

    COPY CODE
    
    add_action( ‘bp_template_content’, ‘my_profile_page_show’ );
    bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );
    

    The problem with Kleo is the fact that I can’t use plugins as the template as there is no header nor footer inside. So I search which was the Buddypress template, I found the Buddypress.php who seems to be the template, but instead of a hook to replace the content, there is the function: “the_content()”, and I don’t know how to use it.

    So how can I make this things work ????

    Here is my code, I put that in my child theme functions.php:

    COPY CODE
    
    function my_setup_nav() {
          global $bp;
    
          bp_core_new_nav_item( array( 
                'name' => __( 'my profile', 'buddypress' ), 
                'slug' => 'my-profile', 
                'position' => 100, 
                'screen_function' => 'my_profile_page', 
          ) );
    }
    
    add_action( 'bp_setup_nav', 'my_setup_nav' );
    
    function my_profile_page() {
            add_action( ‘bp_template_content’, ‘my_profile_page_show’ );
    	bp_core_load_template( 'members/single/plugins' );
    }
    
    function my_profile_page_show() {
    	bp_core_load_template( 'members/single/my_template' );
    }
    
    #17188
     Abe
    Keymaster

    Hi, this code work for me to add a custom tab:

    COPY CODE
    
    
    //Buddypress add profile tab
    add_action( 'bp_setup_nav', 'my_test_setup_nav' );
    
    function my_test_setup_nav() {
    	global $bp;
    	$parent_slug = 'test';
    	$child_slug = 'test_sub';
    	//name, slug, screen, position, default subnav
    	bp_core_new_nav_item( 
    					array(
    							'name' => 'Test tab',
    							'slug' => $parent_slug,
    							'screen_function' => 'my_profile_page_function_to_show_screen',
    							'position' => 40,
    							'default_subnav_slug' => $child_slug 
    					) 
    	);
    }
    
    function my_profile_page_function_to_show_screen() {
    
    	//add title and content here – last is to call the members plugin.php template
    	add_action( 'bp_template_title', 'my_profile_page_function_to_show_screen_title' );
    	add_action( 'bp_template_content', 'my_profile_page_function_to_show_screen_content' );
    	bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
    }
    
    function my_profile_page_function_to_show_screen_title() {
    	echo 'Page title';
    }
    
    function my_profile_page_function_to_show_screen_content() {
    	echo 'Page content';
    }
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #17470
     erannou
    Participant

    It works great thank you very much Abe san for your complete answer !

    Erwan.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Additional BuddyPress custom profile tabs’ is closed to new replies.

Log in with your credentials

Forgot your details?