Skip to content

Instantly share code, notes, and snippets.

@imath imath/bp-custom.php Secret

Created Aug 15, 2019
What would you like to do?
Set the Edit xProfile Subnav as the default one for self users xProfile nav.
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
function eloyruiz_edit_view_as_default_subnav() {
$bp = buddypress();
// Make sure other users than the current one will get the public view
if ( ! bp_is_my_profile() ) {
// Edit the main nav to use the Edit subnav as default.
$bp->members->nav->edit_nav( array(
'link' => sprintf( '%1$s%2$s%3$s',
trailingslashit( bp_loggedin_user_domain() ),
trailingslashit( bp_get_profile_slug() ),
'screen_function' => 'xprofile_screen_edit_profile',
'default_subnav_slug' => 'edit',
), 'profile' );
// Remove the public nav.
$bp->members->nav->delete_nav( 'public', 'profile' );
add_action( 'bp_xprofile_setup_nav', 'eloyruiz_edit_view_as_default_subnav' );
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.