Tagged: combine profile tabs
Hello, I have been researching the efficacy of merging two subnav tabs, for example, if I wanted to merge settings/general and settings/notifications. I understand that this is not an easy task as both are loaded from their own templates. However, easy or not I would like to accomplish this. I have tried to create a new tab first and then load the templates from each using bp_core_load_template, however, only the first template is loaded and the second is disregarded. Is there any real way to accomplish this?
Thank you for your time
Hi John,
Can you please post the complete code? Use bp_get_template_part instead. bp_core_load_template calls exit so it only loads the first template.Here is a way to do it
1. Use bp_core_load_template to load our custom file
2. In the custom file use bp_get_template_part to load both the files.Hope that helps.
Regards
BrajeshHi Brajesh, that is actually what I wound up doing and so far so good. However I have ran into an additional problem that I hope you can help me with.
How can I now set my new tab as the default settings tab? The new tab slug is accountdetails
I have tried using this code in functions.php but it is not working.
function change_default_settings_tab() {
$bp = buddypress();
bp_core_new_nav_default(array(‘parent_slug’=>’$bp->settings->slug’, ‘subnav_slug’ => $bp->settings->slug . ‘/accountdetails’));
}
add_action(‘bp_setup_nav’, ‘change_default_settings_tab’, 5);Hi John,
Thank you for the details.I have slightly modified your code
function change_default_settings_tab() { $bp = buddypress(); bp_core_new_nav_default( array( 'parent_slug' => $bp->settings->slug, 'subnav_slug' => 'accountdetails', 'screen_function' => 'your_function_that_loads_templates' //change it ) ); } add_action( 'bp_settings_setup_nav', 'change_default_settings_tab', 5 );
Note the ‘screen_function’ key. Please make sure to pass your screen function that loads the template( which you used while registering the nav item). Also, subnav slug only needs the slug not the complete parent/child.
Please let me know if it worked for you or not?
Thank you
Brajesh
The topic ‘ [Resolved] Merging subnav tabs’ is closed to new replies.