Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] New profile menu tabs and sub tabs not working correctly

  • @jaykdoe

    Participant

    First of all, I’ve seen alot of people trying to do a similar task, which is simply to create a new tab, with sub tabs in the user profile menu. I’ve managed to do this, but I can’t seem to get the url slug to work properly. When I click on the first sub tab, it simply takes me back to the main page for the user profile, and when I click on any additional sub tabs I get 404 errors. I have a feeling I’m missing something pretty simple, and I’ve been trying to learn over the last couple weeks how to make this work without any luck. If someone could help guide me on how to get this working properly, I would very grateful, and I imagine many others would find this post useful in the future.

    Here is the code I currently have in my bp-custom.php file

    
    // My Membership Profile Tab
    function profile_new_nav_item() {
    
        global $bp;
    
        bp_core_new_nav_item(
        array(
            'name'                => 'My Membership',
            'slug'                => 'my-membership',
            'default_subnav_slug' => 'extra_sub_tab', // We add this submenu item below
            'screen_function'     => 'view_manage_tab_main'
        )
        );
    }
    
    add_action( 'bp_setup_nav', 'profile_new_nav_item', 10 );
    
    function view_manage_tab_main() {
        add_action( 'bp_template_content', 'bp_template_content_main_function' );
        bp_core_load_template( 'template_content' );
    }
    
    function bp_template_content_main_function() {
        if ( ! is_user_logged_in() ) {
            wp_login_form( array( 'echo' => true ) );
        }
    }
    
    function profile_new_subnav_item() {
        global $bp;
    
        bp_core_new_subnav_item( array(
            'name'            => 'Membership Level',
            'slug'            => 'extra_sub_tab',
            'parent_url'      => $bp->loggedin_user->domain . $bp->bp_nav[ 'extra_tab' ][ 'slug' ] . '/',
            'parent_slug'     => $bp->bp_nav[ 'my-membership' ][ 'slug' ],
            'position'        => 10,
            'screen_function' => 'view_manage_sub_tab_main'
        ) );
    }
    
    add_action( 'bp_setup_nav', 'profile_new_subnav_item', 10 );
    
    function view_manage_sub_tab_main() {
        add_action( 'bp_template_content', 'bp_template_content_sub_function' );
        bp_core_load_template( 'template_content' );
    }
    
    function bp_template_content_sub_function() {
        if ( is_user_logged_in() ) {
            //Add shortcode to display content in sub tab
    		echo do_shortcode( '[membership]' );
        } else {
            wp_login_form( array( 'echo' => true ) );
        }
    }
    
    // My Billing Profile Tab
    
    function profile_new_subnav_item_billing() {
        global $bp;
    
        bp_core_new_subnav_item( array(
            'name'            => 'Billing',
            'slug'            => 'extra_sub_tab_billing',
            'parent_url'      => $bp->loggedin_user->domain . $bp->bp_nav[ 'extra_tab' ][ 'slug' ] . '/',
            'parent_slug'     => $bp->bp_nav[ 'my-membership' ][ 'slug' ],
            'position'        => 20,
            'screen_function' => 'view_manage_sub_tab_billing'
        ) );
    }
    
    add_action( 'bp_setup_nav', 'profile_new_subnav_item_billing', 20 );
    
    function view_manage_sub_tab_billing() {
        add_action( 'bp_template_content', 'bp_template_content_sub_function_billing' );
        bp_core_load_template( 'template_content' );
    }
    
    function bp_template_content_sub_function_billing() {
        if ( is_user_logged_in() ) {
            //Add shortcode to display content in sub tab
    		echo do_shortcode( '[billing]' );
        } else {
            wp_login_form( array( 'echo' => true ) );
        }
    }
    
Viewing 4 replies - 1 through 4 (of 4 total)
  • @shanebp

    Moderator

    bp_core_load_template( 'template_content' );

    should be

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

    @jaykdoe

    Participant

    @shanebp, thanks so much for the response, I really appreciate your guidance on this. I went ahead and made the changes you suggested in all three instances, and while this may have been a part of my issue it doesn’t seem to have resolved it.

    The problem I am experiencing is the same as before. The main tab works as it should. but clicking on the first sub nav tab takes me back to the base user profile url and clicking on the second sub nav tab gives me a 404 error. It appears to be an issue with the slug or parent slug, but I’m still very new to all of this so it’s not extremely easy for me to define the exact root cause of the issue.

    Again, thanks so much for the help, but my issue still remains. If you see anything else that stands out to you, please do let me know. Thanks again!

    @shanebp

    Moderator

    @jaykdoe

    Participant

    This is EXACTLY what I needed. THANK YOU!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] New profile menu tabs and sub tabs not working correctly’ is closed to new replies.
Skip to toolbar