This topic has 2 replies, 2 voices, and was last updated 9 years by akal.

  • Author
  • #75996
     akal
    Participant

    Hi,

    I read many topics about the creation of new tab in the profile menu
    I found this function which does the job :

    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’;
    }

    BUT, this new tab can’t be linked to a specific wp page…

    After spent hours searching, I finaly found that from @danbp on buddypress.org
    (https://buddypress.org/support/topic/bp-bp_options_nav-wrong-user-links/)

    function bpfr_my_setup_nav() {
    global $bp;

    $mytab=array(
    ‘name’ => ‘My Tab’,
    ‘link’ => ‘http://example.com/wp-content/themes/twentythirteen/my_extra_page.php’,
    ‘slug’ => ‘my-tab’,
    ‘css_id’ => ‘my_custom_tab’,
    ‘position’ => 100,
    ‘user_has_access’ => 1,
    ‘screen_function’ => ‘xprofile_screen_my_tab’
    );
    $bp->bp_options_nav[‘profile’][‘my-tab’]=$mytab;
    }
    add_action(‘bp_setup_nav’, ‘bpfr_my_setup_nav’);

    This function added a new “sub tab” in the “My profile” section and “My tab” does a link to http://example.com/wp-content/themes/twentythirteen/my_extra_page.php which go out from the /members/ directory loop.

    So, I would like to add a new tab in the profile menu by using the first function that will be able to link to one of my wp page, which will not be like /members/usernane/my_page but http://mysite/my_page

    I hope I was clear enough… Please help :p

    #76019
     sharmstr
    Moderator

    The bp_core_new_nav_item function will never do that. Its sole purpose is to load a submenu and an associated screen. If you are okay displaying the page within the profile screen, then you can use this plugin: https://wordpress.org/plugins/buddypress-custom-profile-menu/screenshots/

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #76033
     akal
    Participant

    Hi sharmstr,

    thank you for your fast reply;

    I’ll try this plug, thanks !

    Akal

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

The forum ‘KLEO’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?