Hello @robertherold,
So you need basically redirect from subpages to user profile.
Correct?
I will post action hook, give me a moment.
All right so you have above defined 4 links. 4 subpages and we want to redirect redirect them to user profile main page.
We need to use hook to redirect those pages
add_action( 'template_redirect', 'redirect_user_to_profile_from_subpages' );
function redirect_user_to_profile_from_subpages() {
global $wp;
// subpage - enagements
if ($wp->query_vars["bbp_engagements"] == 1 ) {
wp_safe_redirect( bbp_get_user_profile_url( get_current_user_id() ) );
exit;
}
// subpage - topics created
if (bbp_is_topics_created()) {
wp_safe_redirect( bbp_get_user_profile_url( get_current_user_id() ) );
exit;
}
// subpage - replies created
if (bbp_is_replies_created()) {
wp_safe_redirect( bbp_get_user_profile_url( get_current_user_id() ) );
exit;
}
// subpage - subscriptions
if (bbp_is_subscriptions()) {
wp_safe_redirect( bbp_get_user_profile_url( get_current_user_id() ) );
exit;
}
}
Let me know if this works for you.
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;
}
}
You do not want to give access to profile subpages to other forum participants.
Yes, you are rock.
I do not use operand and
. I like &&
.
Glad you like it 😊🐱😝
Thank you very much again for your help! 😀 😉