Use Case : You want to use WPLMS only as a directory and host your courses elsewhere like on Undemy.


In such cases you may want to display price and redirect the user to udemy when user clicks on "Take this course" button.


Here's how you can achieve this :


Paste the code in child theme functions.php file or wplms customizer/wplms_customizer.php file


STEP 1 : Extend the Course Settings box with External Link


   

add_filter('wplms_course_metabox','wplms_add_udemy_link');
function wplms_add_udemy_link($settings){
    $settings['vibe_udemy_link'] = array( 
            'label' => 'Udemy Link',
            'desc'  => 'External link to Udemy course',
            'id'    =>  'vibe_udemy_link',
            'type'  => 'text',
                    'std'   => ''
                    );
    return $settings;
}

   


Result :




STEP 2 : Connect the Take this course button to the external link


   

add_filter('wplms_course_product_id','wplms_udemy_link',10,2);
function wplms_udemy_link($link,$course_id){
	$udemy_link = get_post_meta($course_id,'vibe_udemy_link',true);
        if(isset($udemy_link) && $udemy_link)
  		$link = $udemy_link;

	return $link;
}

   


To open this in new window :


 

add_filter('wplms_course_product_id','wplms_udemy_link',10,2);
function wplms_udemy_link($link,$course_id){
    $udemy_link = get_post_meta($course_id,'vibe_udemy_link',true);
        if(isset($udemy_link) && $udemy_link){
           $link = $udemy_link.'" target="_blank';
        }
    return $link;
}