Are you looking for a way to redirect author archive page to author’s BuddyPress user profile? While there’s probably a plugin for this, we have created a quick code snippet that you can use to redirect author archive page to author’s BuddyPress user profile in WordPress.
Instructions:
All you have to do is add this code to your theme’s functions.php file or bp-custom.php file:
function buddydev_author_redirect_to_profile() { if ( is_author() && function_exists( 'bp_core_redirect' ) ) { $author_id = get_queried_object_id(); bp_core_redirect( bp_core_get_user_domain( $author_id ) ); } } add_action( 'template_redirect', 'buddydev_author_redirect_to_profile' );
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 10 best WordPress testimonial plugins to add social proof and how to set up download tracking in WordPress with Google Analytics.
Comments Leave a Reply