Skip to:
Content
Pages
Categories
Search
Top
Bottom

change default subnav

  • @psmorrow

    Participant

    I’m having the worst time trying to change the default subnav on a user’s profile page. I came across this code snippet, but it doesn’t seem to work.

    function change_settings_subnav() {
    	$args = array(
    		'parent_slug' => 'settings',
    		'screen_function' => 'bp_core_screen_notification_settings',
    		'subnav_slug' => 'notifications'
    	);
     
    	bp_core_new_nav_default($args);
    }
    add_action('bp_setup_nav', 'change_settings_subnav', 5);
    

    …and the reason this won’t work according to hookr.io is:
    bp_core_screen_notification_settings();
    This function is no longer needed as new template files for the Settings component were introduced.

    I’ll be most grateful if anyone can help me!

Viewing 8 replies - 1 through 8 (of 8 total)
  • @shanebp

    Moderator

    It’s unclear what you’re trying to do.
    But to add a tab to a subnav, you should use bp_core_new_subnav_item.

    @psmorrow

    Participant

    Thanks for the reply. I’ll try to explain what I’m trying to do: I’m using the Events Manager plug in, and for the Events tab, I want to default to the tab named “Events I’m Attending” (slug is ‘attending’). I’m hiding the previous tabs, which is why i want to default to the named attending

    If you aren’t familiar with the Events Manager plug in, I’m happy to stick to the hypothetical example of my snippet above, in which I try (but not successfully) to set the default sub-tab of the settings tab to ‘notifications’.

    Hope this helps explain things!

    @shanebp

    Moderator

    You’re trying to use a deprecated approach – don’t.

    You may need to adjust the default_subnav_slug in the call to bp_core_new_nav_item, if that’s how they are creating the Events tab.

    Have you tried asking the creators of the Events Manager plugin ?

    @psmorrow

    Participant

    Tried this, without success:

    function bp_change_default_subnav() {
    	global $bp;	
    	bp_core_new_nav_item( array(
    		'name'                  => 'Events',
    		'slug'                  => 'events',
    		'parent_url'            => $bp->displayed_user->domain,
    		'parent_slug'           => $bp->profile->slug,		
    		'position'              => 700,
    		'default_subnav_slug'   => 'attending'
    	) );
    }
    add_action( 'bp_setup_nav', 'bp_change_default_subnav', 100 );
    

    Any suggestions?

    @psmorrow

    Participant

    Just to clarify, the Events tab already exists. I am trying to change the default sub-tab of ‘events’ to the subtab named ‘attending’

    @psmorrow

    Participant

    Got this working today:

    function bp_change_default_subnav() {
    	global $bp;	
    	bp_core_new_nav_item( array(
    		'name'                  => 'Events',
    		'slug'                  => 'events',
    		'parent_url'            => $bp->displayed_user->domain,
    		'parent_slug'           => $bp->profile->slug,		
    		'position'              => 800,
    		'default_subnav_slug'   => 'attending'
    	) );
    }
    add_action( 'bp_setup_nav', 'bp_change_default_subnav', 5 );
    

    @jexley

    Participant

    After a few hours of searching I found this page, pasted your last code snippet in, and it worked a treat. Cheers!

    @southcitymotorbodyworks

    Participant

    Its not working for me, suggest me some other option guys! Panel Beater South Melbourne 

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.