Hi There,
Can I Redirect A Page having Query Strings including User ID to their Respective Buddypress Profile Pages?
What I mean is Like Redirecting example.com/profile/?id=187 to Their Respective Buddypress profile Page?
If The User ID 187 Belongs to John, the Page will be Redirected to example.com/members/john/ ?Thank You,
CromacioHello Princy,
Thank you for posting. Please try the following code it will redirect to user profile based on user_id in the query string.
add_action( 'bp_template_redirect', function () { $user_id = empty( $_GET['user_id'] ) ? '' : wp_unslash( $_GET['user_id'] ); $user = get_user_by( 'id', $user_id ); if ( ! $user ) { return; } bp_core_redirect( bp_core_get_user_domain( $user->ID ) ); } );
Please let me know if it helps or not.
Regards
RaviHi Ravi,
Thanks for Reply.Unfortunately, that Didn’t Work.
Would Using Cloudflare Caching Cause an Issue? As that Adds Another Query String?
If Not, The Complete Permalink, I’m Trying to Work with is This – /profile/?uid=29&swcfpc=1Thank You 🙂
Cromacio
The topic ‘ [Resolved] Redirection to Buddypress Profile using Query Strings’ is closed to new replies.