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 :
    [popup id=”470″ auto=”0″ classes=”default”][/popup]
    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
            } 
        }
    }

     

Was this article helpful?

Related Articles

2 Comments

  1. kasperalik

    Hi
    I tried it, but I got an error, an empty popup

  2. IT-Pomeroy

    Hi,
    It doesn’t work for me although I have been following your instruction . Any Advice?

Leave A Comment?