BuddyDev

Changing Default Subnav for a BuddyPress Component

When you click on a component on the BuddyPress User profile, the default subnav is the screen that will get rendered. Default subnav is registered when a component is registered with BuddyPress. BuddyPress does allows us changing it using the bp_core_new_nav_default function. It has following signature.

The screen_function is optional. I suggest providing as much details as possible. In the code below, we are going to explore various ways to use it.

Example 1:- Changing the default subnav for activity from Personal to mentions

 

Example 2:- Changing Default Settings Screen to Notifications settings

Now that you understand it, let us get a little bit creative.

Context based default screen:-

Yes, you can change the default screen based on current user. Here is an example where we change the default screen for profile to be edit profile if the user is viewing their own profile else we leave it as view profile.

I guess I will stop here and let you experiment further. Do let me know if you plan to do something interesting with it or already did it 🙂

 

6 Responses to Changing Default Subnav for a BuddyPress Component

  • Also what I was desperately looking for 🙂 Thanks again!!

  • Seems that the code doesnt work anymore with version 3.1.0. I tried both code examples and in both cases I receive a page not found when click in activity or settings menu.

    • Hi Leandro,
      I can confirm this. It will be most probably fixed in upcoming 3.2

  • Any news here? Changing default subnav based on displayed user profile would be great for me, guess i could do with the snippet replacing bp_is_my_profile() with bp_displayed_user_xxx function. Hope its working again soon 🙂

    • Sorry about this. Like I mentioned on forum, the current version of BuddyPress does not support it.