Need to get hooks when someone completes a course

Hi,

I am making some modifications to the plugin and wanted my code to be triggered when a new course was made, and when one course was completed by the user.

What I am trying to do here, is make a compulsory gap of 7days between 2 different courses. I was planning to run WP_CRON to check that and needed a hook so my code could know when the course was done. Any better way to do this?

I will need a hook/signal that a course has been created, I will also need to hook/signal when the user just completed a course. Please let me know.

  • Vinod Dalvi
    • WP Unicorn

    Hi @Andrew,

    I hope you are well today and thank you for your question.

    I have notified our SLS developer to get his reply regarding whether there is any which triggeres when a new course was made and when one course was completed by the user.

    The developer will reply here shortly.

    Thanks,
    Vinod Dalvi

  • Marko Miljus
    • The Incredible Code Injector

    Hi Andrew,

    you should be able to hook when new course is created like this:

    add_action( 'publish_post', 'new_course_created',10,2 );
    function new_course_created($post_id, $post)
    {
    if(get_post_type( $post_id ) == 'course'){
    //checks whether is post updated or published at first time.
    if ($post->post_date != $post->post_modified) return;
    
     //do something when new course is created
    }
    }

    In regards to the hook for completed course, I'll take a look at that one soon.

    Cheers,
    Marko

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.