Customize the LearnDash Course Grid Button

Place this code after you edit it into your child theme’s functions.php file:

function elc_learndash_course_grid_custom_button_link( $button_link, $post_id ) {

switch ( $post_id ) {
// add one case for each course post_id
// 221 is the beatles course, 264 is the who course
case 221:
if ( is_user_logged_in() ) {
return “https://www.google.com/”;
} else {
return home_url( $path = ‘/my-login/’ );
}
break;

case 264:
return home_url( $path = ‘/my-profile/’ );
break;

// no match for this course so send back the normal button link
default:
return $button_link;
break;
}
}

add_filter( ‘learndash_course_grid_custom_button_link’, ‘elc_learndash_course_grid_custom_button_link’, 99, 2 );