Tagged: buddypress, redirect
I have been trying the following code so that when I see a profile of another user, send me to the following url:
site.com/members/USERNAME/reviews
all the code works except the line
bp_core_redirect('./reviews' );
my code is:
function bpfr_hide_tabs() { global $bp; if( class_exists( 'bbPress' ) || bp_is_active ( 'groups' ) ) : if ( bp_is_user() && !is_super_admin() && !bp_is_my_profile() ) { bp_core_redirect('./reviews' ); bp_core_remove_nav_item( 'activity' ); } endif; } add_action( 'bp_setup_nav', 'bpfr_hide_tabs', 15 );
Any suggest? Thanks!!!
Hello Jennifer,
Thank you for posting. Please clear me out for the following points.
1. Is ‘reviews’ is custom WordPress page or user profile tab?.
2. Do you want to redirect user for all tabs of user profile or certain tabs?.
3. Is there any need to remove activity nav item?.Please let me know.
Regards
RaviHi Revi!
1. Reviews is a tab of profile page ( like activity or message) but I dont have the name to redirect ( because I didnt create it..). I have tried with define(‘ BP_DEFAULT_COMPONENT’, ‘reviews’ ) but it dont works.2. Yes. I want redirect to all the users that are looking other profile to tabs of reviews
3. Yes I want hide all the tabs except reviews.members/USERNAME/reviewsThanks very much!!
Regards
JenniferHello Jenifer,
Thank you for sharing the details. Please try the following code and let me know if works for you or not.
function buddydev_redirect_to_reviews() { if ( bp_is_user() && ! bp_is_my_profile() && ! bp_is_current_component( 'reviews' ) ) { $user_domain = bp_core_get_user_domain( bp_displayed_user_id() ); $review_url = trailingslashit( $user_domain ) . 'reviews'; bp_core_redirect( $review_url ); } } add_action( 'bp_template_redirect', 'buddydev_redirect_to_reviews' );
Regards
Ravi
You must be logged in to reply to this topic.