Skip to content

Commit

Permalink
Add compatibility with BuddyPress version 12.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbillion committed Feb 20, 2024
1 parent ece181f commit 0c5c02e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/phpstan/stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ function bp_get_member_user_id() {}
*/
function bp_core_get_user_domain( int $user_id ) {}

/**
* @return string
*/
function bp_members_get_user_url( int $user_id ) {}

/**
* @return string
*/
Expand Down
10 changes: 9 additions & 1 deletion user-switching.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,16 @@ public function action_bp_button() {
return;
}

if ( function_exists( 'bp_members_get_user_url' ) ) {
$redirect_to = bp_members_get_user_url( $user->ID );
} elseif ( function_exists( 'bp_core_get_user_domain' ) ) {
$redirect_to = bp_core_get_user_domain( $user->ID );
} else {
$redirect_to = home_url();
}

$link = add_query_arg( array(
'redirect_to' => rawurlencode( bp_core_get_user_domain( $user->ID ) ),
'redirect_to' => rawurlencode( $redirect_to ),
), $link );

$components = array_keys( buddypress()->active_components );
Expand Down

0 comments on commit 0c5c02e

Please sign in to comment.