Skip to content

Instantly share code, notes, and snippets.

@imath
Last active February 3, 2020 17:05
Show Gist options
  • Save imath/e964da41a85b9e76b679fb946114219c to your computer and use it in GitHub Desktop.
Save imath/e964da41a85b9e76b679fb946114219c to your computer and use it in GitHub Desktop.
Edit BuddyPress primary nav so that profile primary item is before the activity primary item
<?php
/**
* BuddyPress 2.6.0 introduced a new nav API
* with a Backcompat mechanism. But accessing/editing
* deprecated globals can lead to such problems...
*
* It's too bad Theme designers forget to test betas :)
*/
function strothi_profile_primary_nav_first() {
buddypress()->members->nav->edit_nav( array(
'position' => 6,
), 'profile' );
}
add_action( 'bp_xprofile_setup_nav', 'strothi_profile_primary_nav_first' );
// You'll probably need to also have the profile defined as default component..
function strothi_profile_as_front_page() {
if ( defined( 'BP_DEFAULT_COMPONENT' ) ) {
return;
}
define( 'BP_DEFAULT_COMPONENT', 'profile' );
}
add_action( 'bp_init', 'strothi_profile_as_front_page', 5 );
@imath
Copy link
Author

imath commented Jul 5, 2016

good catch! Just fixed it!

@danbp
Copy link

danbp commented Jul 6, 2016

Another detail, about the first function action filter. bp_xprofile_setup_nav doesn't exist and the function can't work
If you use this in addition with priority, it does:

add_action( 'bp_setup_nav', 'strothi_profile_primary_nav_first',999 );

I'm also curious to know how to move tabs on a group page ? Seems to use a completely different syntax which i'm unable to write correctly. Merci ! ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment