Add popup on clicking on course button for non logged in users.

  1. create a popup from wp-admin -> popups -> add new .
  2. note down the id of the popup .
  3. now come to edit course and add this shortcode in your course description :

    refer : http://prntscr.com/g94k65
  4. then add this code in your wplms-customizer.php file in wplms customizer plugin :
    add_action('wp_footer','check_logged_in_and_form');
    function check_logged_in_and_form(){
        global $post;
        $course_id = $post->ID;
        if(is_singular('course')){
           if((!is_user_logged_in()) || (is_user_logged_in() && function_exists('bp_course_is_member') && !bp_course_is_member($course_id,get_current_user_id()))){
                ?>
                <script>
                jQuery(document).ready(function($){
                    $('a.course_button').on('click',function(event){
                      event.preventDefault();
                        $('.ajax-popup-link').trigger('click');
                    });
                });
                </script>
                <?php
            } 
        }
    }

     

Leave a Reply

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