PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 All 140 releases
← All changes | inc/user/abstract-lp-user.php +12 -0 4.4.7 → 4.4.9 View file →
@@ -645,8 +645,20 @@
645 645 //$user_course->save();
646 646 $return = $user_course->complete( LP_COURSE_FINISHED );
647 647
648 648 if ( $return ) {
649 + /**
650 + * LP_User_Item::complete() writes straight to the table, so it never runs
651 + * UserCourseModel::clean_caches() the way UserItemModel::save() does. The
652 + * cached model still reports the enrollment as in progress, and that cache
653 + * outlives the request wherever a persistent object cache is installed - the
654 + * course then reads back unfinished and keeps offering "Finish course".
655 + */
656 + $userCourseModel = UserCourseModel::find( $this->get_id(), $course_id );
657 + if ( $userCourseModel instanceof UserCourseModel ) {
658 + $userCourseModel->clean_caches();
659 + }
660 +
649 661 do_action( 'learn-press/user-course-finished', $course_id, $this->get_id(), $return );
650 662 }
651 663 }
652 664