Title: Course Completed Hook
Last modified: December 21, 2023

---

# Course Completed Hook

 *  Resolved [Andrew](https://wordpress.org/support/users/andrew1111/)
 * (@andrew1111)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/course-completed-hook/)
 * Hello,
 * We would like a custom action to execute when certain courses are completed. 
   To do this, the ID of the course is needed to determine if the action should 
   be taken.
 * We’ve created a hook for the filter “_**masterstudy\_lms\_course\_player\_completed**_“.
   Our filter runs after the MasterStudy filter function **_“masterstudy\_lms\_course\
   _player\_completed”_** , so we can determine if the course was passed. The challenge
   is the MS filter function returns an array that does not contain the course ID.
   We can get the lesson ID from the filter parameters, but we couldn’t find a way
   to uniquely identify the course, based on lesson ID.
 * At first glance, it appears a simple fix might work:
 * [https://plugins.trac.wordpress.org/browser/masterstudy-lms-learning-management-system/trunk/_core/lms/course-player/cp-template-functions.php#L620](https://plugins.trac.wordpress.org/browser/masterstudy-lms-learning-management-system/trunk/_core/lms/course-player/cp-template-functions.php#L620)
 *     ```wp-block-code
       return array(
       		'course_id'               => post_id, // ID of the completed course.
       		'lesson_completed'        => STM_LMS_Lesson::is_lesson_completed( null, $post_id, $item_id ),
       		'passed'                  => ! empty( $passed ) ? $passed : false,
       		'disable_smile'           => STM_LMS_Options::get_option( 'finish_popup_image_disable', false ),
       		'custom_failed_image_id'  => STM_LMS_Options::get_option( 'finish_popup_image_failed' ),
       		'custom_success_image_id' => STM_LMS_Options::get_option( 'finish_popup_image_success' ),
       		'failed_image'            => STM_LMS_URL . 'assets/icons/lessons/course-completed-negative.svg',
       		'success_image'           => STM_LMS_URL . 'assets/icons/lessons/course-completed-positive.svg',
       	);
       ```
   
 * Please let us know the best method to get the ID of the completed course.
 * Thank you

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Support [juliastylemixthemes](https://wordpress.org/support/users/juliastylemixthemes/)
 * (@juliastylemixthemes)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/course-completed-hook/#post-17295744)
 * Hello [@andrew1111](https://wordpress.org/support/users/andrew1111/),
 * Gently note, our support team is able to assist with the LMS Free plugin default
   settings and options only. Your request is considered as an item customization.
 * However, I have asked our dev team to check your case and was informed that this
   filter will be removed with upcoming update. And only Action hooks might be useful
   for you, as Filter hooks are only for modiying the Data.
 * Please try to use this Action instead:
    1. **stm_lms_lesson_passed** – runs when Lesson Completed, but Course may be still
       not finished here:
       `do_action( 'stm_lms_lesson_passed', $user_id, $lesson_id,
       $course_id )`
    2. stm_lms_progress_updated – runs when Lesson Completed, $progress value will 
       be 100, when Course finished:
       `do_action( 'stm_lms_progress_updated', $course_id,
       $user_id, $progress );`
 * Best regards,
 *  Thread Starter [Andrew](https://wordpress.org/support/users/andrew1111/)
 * (@andrew1111)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/course-completed-hook/#post-17298479)
 * Thank you for the helpful response. We will use the suggested actions.
 *  Plugin Support [mgordon7](https://wordpress.org/support/users/mgordon7/)
 * (@mgordon7)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/course-completed-hook/#post-17300133)
 * Thank you, and we appreciate your kind words!
 * If you find our LMS plugin valuable, we would be grateful if you could take a
   moment to leave a 5-star review. Your feedback serves as a strong motivation 
   for our entire plugins team to persistently enhance and refine our plugin. Your
   support means a lot to us, and we truly appreciate it.
 * Best regards

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Course Completed Hook’ is closed to new replies.

 * ![](https://ps.w.org/masterstudy-lms-learning-management-system/assets/icon-256x256.
   gif?rev=2846471)
 * [MasterStudy LMS WordPress Plugin – for Online Courses and Education](https://wordpress.org/plugins/masterstudy-lms-learning-management-system/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/masterstudy-lms-learning-management-system/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/masterstudy-lms-learning-management-system/)
 * [Active Topics](https://wordpress.org/support/plugin/masterstudy-lms-learning-management-system/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/masterstudy-lms-learning-management-system/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/masterstudy-lms-learning-management-system/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [mgordon7](https://wordpress.org/support/users/mgordon7/)
 * Last activity: [2 years, 5 months ago](https://wordpress.org/support/topic/course-completed-hook/#post-17300133)
 * Status: resolved