Skip to content

Instantly share code, notes, and snippets.

@imath
Created August 15, 2019 04:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imath/113ad3226c9a01ac56c2d2edabb458f3 to your computer and use it in GitHub Desktop.
Save imath/113ad3226c9a01ac56c2d2edabb458f3 to your computer and use it in GitHub Desktop.
Set the Edit xProfile Subnav as the default one for self users xProfile nav.
<?php
// 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() ) {
return;
}
// 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() ),
'edit'
),
'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