Redirect to different page after switching
-
Hi there,
I’m using buddyboss which has the member switching plugin worked into it. So I’m trying to redirect to a user’s friends section (/friends) on their profile instead of their main profile page by creating a function that goes into functions.php file. After reading through several topics I’ve ended up with this code snippet but it doesn’t change the switch to destination. Could you please help me achieve this or guide in the right direction… please?
function modify_bbpress_button_link() { $user = get_userdata( bbp_get_user_id() ); if ( ! $user ) { return; } $link = self::maybe_switch_url( $user ); if ( ! $link ) { return; } $link .= 'friends/'; $link = add_query_arg( array( 'redirect_to' => urlencode( bbp_get_user_profile_url( $user->ID ) ), ), $link ); ?> <ul id="bp_member_switching_switch_to"> <li><a href="<?php echo esc_url( $link ); ?>"><?php esc_html_e( 'Switch To', 'buddyboss' ); ?></a></li> </ul> <?php } add_action('switch_to_user', 'modify_bbpress_button_link');
Best regards,
Nella
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Redirect to different page after switching’ is closed to new replies.