Redirect Non-logged in Users to Register Page when they click on Take this course button

Please add this code in your wplms-customizer.php file present in your wplms customizer plugin (go to wp-admin->plugins->editor->select wplms customizer plugin and add the code in wplm-customizer.php file) OR add the code in the function.php file of your child theme (if using a child theme):

add_filter('wplms_take_course_button_html','custom_non_loggedin_user_redirect',10,2);
add_filter('wplms_course_non_loggedin_user','custom_non_loggedin_user_redirect',10,2);
add_filter('wplms_private_course_button_html','custom_non_loggedin_user_redirect',10,2);

function custom_non_loggedin_user_redirect($html,$course_id){
  if(!is_user_logged_in()){
    $extra ='';    
    $page = 'http://vibethemes.com';
    return '<a href="'.$page.'" class="course_button full button">'.apply_filters('wplms_take_this_course_button_label',__('TAKE THIS COURSE','vibe'),$course_id).apply_filters('wplms_course_button_extra',$extra,$course_id).'</a>'; 
  }
  return $html;
}

NOTE: Please change the url “http://vibethemes.com” to your register page url

Leave a Reply

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