How to redirect to instructor’s BuddyPress Profile from Single course page?

By Default, On clicking the instructor’s name from the single course page, Users will be redirected to the instructor’s Learndash page, where all of his courses will be listed.

But, If somebody wants to set this redirection to the instructor’s BuddyPress Profile, He can add the following code snippet to the functions.php file.

/**
 * This code snippet is for redirect instructor author url to buddypress profile.
 *
 * @param  string $insttuctor_id Get a Default instructor url.
 * @return string Return the instructor bp profile url.
 */
function ld_redirect_author_url( $insttuctor_url ) {
	$course_id      = learndash_get_course_id();
	$user_id        = get_post_field( 'post_author', $course_id );
	$insttuctor_url = bp_core_get_user_domain( $user_id );
	return $insttuctor_url;
}
add_filter( 'lm_filter_course_author_url', 'ld_redirect_author_url', 10, 1 );

Leave a Reply

Your email address will not be published. Required fields are marked *

Update on May 26, 2022