Reply To: Another user’s edit page jumps to the profile page
Thank you very much, it was very good. I added a bit because I want the user to access their own links, but not other users.
I did it well?
add_action( 'template_redirect', 'redirect_user_to_profile_from_subpages' );
function redirect_user_to_profile_from_subpages() {
global $wp;
$user_id = bbp_get_displayed_user_id();
// subpage - enagements
if ($wp->query_vars["bbp_engagements"] == 1 and $user_id != get_current_user_id() ) {
wp_safe_redirect( bbp_get_user_profile_url( $user_id ) );
exit;
}
// subpage - topics created
if (bbp_is_topics_created() and $user_id != get_current_user_id() ) {
wp_safe_redirect( bbp_get_user_profile_url( $user_id ) );
exit;
}
// subpage - replies created
if (bbp_is_replies_created() and $user_id != get_current_user_id() ) {
wp_safe_redirect( bbp_get_user_profile_url( $user_id ) );
exit;
}
// subpage - subscriptions
if (bbp_is_subscriptions() and $user_id != get_current_user_id() ) {
wp_safe_redirect( bbp_get_user_profile_url( $user_id ) );
exit;
}
}