Skip to content

Commit

Permalink
BuddyPress: unhook broken BP_Member_Admin:profile_nav. (#47)
Browse files Browse the repository at this point in the history
This commit prevents the BuddyPress profile navigation UI from triggering our "Other" compatibility section, and also fixes a related profile.php redirection issue.
  • Loading branch information
JJJ authored Nov 11, 2020
1 parent d9e8a81 commit 6291bef
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
7 changes: 6 additions & 1 deletion wp-user-profiles/includes/capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ function wp_user_profiles_current_user_can_edit( $user_id = 0 ) {
* @param type $user
*/
function wp_user_profiles_old_profile_redirect() {
wp_safe_redirect( get_dashboard_url() );

// Get the redirect URL
$url = get_edit_profile_url( get_current_user_id() );

// Do the redirect
wp_safe_redirect( $url );
exit;
}

Expand Down
32 changes: 32 additions & 0 deletions wp-user-profiles/includes/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,3 +476,35 @@ function wp_user_profiles_has_profile_actions() {
// Return true/false
return $retval;
}

/**
* Maybe unhook the BuddyPress Profile Navigation hook
*
* BuddyPress hooks into 'show_user_profile' and 'edit_user_profile' for
* displaying its custom UI, it conflicts with ours, so the best thing we can do
* is avoid the situation completely.
*
* @since 2.4.0
*/
function wp_user_profiles_unhook_bp_profile_nav() {

// Bail if no BuddyPress
if ( ! function_exists( 'buddypress' ) ) {
return;
}

// Get BuddyPress Profile Navigation hook
$bp = buddypress();

// Bail if no Member Admin
if ( empty( $bp->members->admin ) ) {
return;
}

// Get the hook callback
$tag = array( $bp->members->admin, 'profile_nav' );

// Remove the actions
remove_action( 'show_user_profile', $tag, 99 );
remove_action( 'edit_user_profile', $tag, 99 );
}
3 changes: 3 additions & 0 deletions wp-user-profiles/includes/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@
// Nav & Subnav
add_action( 'wp_user_profiles_nav_actions', 'wp_user_profiles_admin_nav', 12 );
add_action( 'wp_user_profiles_nav_actions', 'wp_user_profiles_admin_subnav', 14 );

// BuddyPress
add_action( 'bp_init', 'wp_user_profiles_unhook_bp_profile_nav' );

0 comments on commit 6291bef

Please sign in to comment.