Skip to content

Instantly share code, notes, and snippets.

@imath imath/bp-custom.php
Last active Dec 14, 2016

Embed
What would you like to do?
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 );
@danbp

This comment has been minimized.

Copy link

commented Jul 5, 2016

Thank you for the snippet !
A little error on line 19, missing a closing )
should be if ( defined( 'BP_DEFAULT_COMPONENT' ) ) {

@imath

This comment has been minimized.

Copy link
Owner Author

commented Jul 5, 2016

good catch! Just fixed it!

@danbp

This comment has been minimized.

Copy link

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
You can’t perform that action at this time.