Tuesday, 20 April 2021

Add Custom link and content on fronted dashboard of buddypress

 





CUSTOM PROFILE TAB

function bp_custom_user_nav_item() {

    global $bp;

 

    $args = array(

            'name' => __('Portfolio', 'buddypress'),

            'slug' => 'portfolio',

            'default_subnav_slug' => 'portfolio',

            'position' => 50,

            'show_for_displayed_user' => false,

            'screen_function' => 'bp_custom_user_nav_item_screen',

            'item_css_id' => 'portfolio'

    );

 

    bp_core_new_nav_item( $args );

}

add_action( 'bp_setup_nav', 'bp_custom_user_nav_item', 99 );


SCREEN CALLBACK FUNCTION

function bp_custom_user_nav_item_screen() {

    add_action( 'bp_template_content', 'bp_custom_screen_content' );

    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );

}



SCREEN CONTENT FUNCTION

function bp_custom_screen_content() {

 

   echo 'the custom content. 

    You can put a post loop here, 

    pass $user_id with bp_displayed_user_id()';

 

}

No comments:

Post a Comment