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:
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
- The topic ‘Course Completed Hook’ is closed to new replies.