Justyn Hornor
Justyn Hornor

Reputation: 35

BuddyPress New sub_nav item and screen

How do I get my new sub_nav item to properly display the screen I've created?

I'm using my own child theme. What I'm trying to accomplish is to give my users the ability to create child accounts for their children. I have separate functionality for that and it's working fine.

What works: The "Child Account(s)" tab shows up as expected.

What's broke When clicked, I get a 404 error.

I have a child-account.php in a folder bp-themes/bp-default/members/single/child

What am I missing?

Here's my code:

add_action( 'bp_setup_nav', 'add_subnav_items', 100 ); 
function add_subnav_items() {
    global $bp;

   //Child Account(s) tab
    $tab_array['name'] = 'Child Account(s)';    
    $tab_array['link'] =  $bp->displayed_user->domain.'child';   
    $tab_array['slug'] = 'child';    
    $tab_array['parent_url'] = $bp->displayed_user->domain; 
    $tab_array['parent_slug'] = bp_core_get_userlink(bp_loggedin_user_id());    
    $tab_array['css_id'] = 'child';  
    $tab_array['position'] = 100;   
    $tab_array['user_has_access'] = '1';    
    $tab_array['screen_function'] = 'profile_screen_child_account';

    $bp->bp_nav['child'] = $tab_array; 
}// End add_subnav_items

function profile_screen_child_account() {
    add_action( 'bp_template_content', 'profile_screen_child_account_show' );
    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
}// End profile_screen_child_account

function profile_screen_child_account_show() {
    echo "Manage Child Account Screen";
    locate_template( array( 'child-template.php' ), true );
}// End profile_screen_child_account_show

Upvotes: 0

Views: 947

Answers (1)

shanebp
shanebp

Reputation: 1956

Instead of:

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

Try this:

    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/child/child-account' ) );

Upvotes: 1

Related Questions