Reputation: 87
I am using buddypress for a social media site.
I have create an xprofile field called "About", and also added a new tab in the buddypress pages using the following code.
function custom_setup_nav() {
global $bp;
bp_core_new_nav_item( array(
'name' => __( 'About', 'buddypress' ),
'slug' => 'about',
'position' => 30,
'screen_function' => 'about_page'
) );
}
add_action( 'bp_setup_nav', 'custom_setup_nav' );
Now I have created an about page and named it about.php and uploaded it to /plugins/buddypress/bp-themes/bp-default/members/single
And then added the following screen function
function about_page() {
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/about' ) );
}
Now when I go to about page, I always get the members page displayed there, the page where the list of members are displayed and not the custom about.php page that I have uploaded, although the url remains the same, members/username/about/
Is there something I am missing out on ?
Thanks.
Upvotes: 0
Views: 2755
Reputation: 10240
I think you may need to have a subnav item. Try changing your custom_setup_nav
function to:
global $bp;
bp_core_new_nav_item(
array( 'name' => __( 'About', 'buddypress' ),
'slug' => 'about',
'position' => 30,
'show_for_displayed_user' => true,
'default_subnav_slug' => 'about',
'item_css_id' => 'about'
)
);
bp_core_new_subnav_item(
array( 'name' => __( 'About', 'buddypress' ),
'slug' => 'about',
'parent_url' => $bp->loggedin_user->domain . 'about',
'screen_function' => 'about_page',
'parent_slug' => 'about',
'position' => 10,
'item_css_id' => 'about'
)
);
Also, try creating a folder in your theme directory called /buddypress/
then use the path:
/buddypress/members/single/about
That will ensure your customisations aren't lost each time you upgrade BP. See here for more info on the template hierarchy: http://codex.buddypress.org/themes/theme-compatibility-1-7/template-hierarchy/
Upvotes: 2