diff --git a/classes/Utils.php b/classes/Utils.php index 0f6b312f3..67de5001b 100644 --- a/classes/Utils.php +++ b/classes/Utils.php @@ -9979,13 +9979,15 @@ public function get_local_time_from_unix( $time, $date_format = null ) { * Execute bulk action for enrollment list ex: complete | cancel * * @since 2.0.3 + * @since 3.2.0 $trigger_hook param added. * * @param string $status hold status for updating. * @param array $enrollment_ids ids that need to update. + * @param bool $trigger_hook optional - trigger hook or not. * * @return bool */ - public function update_enrollments( string $status, array $enrollment_ids ): bool { + public function update_enrollments( string $status, array $enrollment_ids, bool $trigger_hook = true ): bool { global $wpdb; $enrollment_ids_in = QueryHelper::prepare_in_clause( $enrollment_ids ); $status = 'complete' === $status ? 'completed' : $status; @@ -10001,9 +10003,11 @@ public function update_enrollments( string $status, array $enrollment_ids ): boo ) ); - // Run action hook. - foreach ( $enrollment_ids as $id ) { - do_action( 'tutor_enrollment/after/' . $status, $id ); + if ( $trigger_hook ) { + // Run action hook. + foreach ( $enrollment_ids as $id ) { + do_action( 'tutor_enrollment/after/' . $status, $id ); + } } return true; diff --git a/ecommerce/HooksHandler.php b/ecommerce/HooksHandler.php index 601721c39..1e3fab0a3 100644 --- a/ecommerce/HooksHandler.php +++ b/ecommerce/HooksHandler.php @@ -308,6 +308,16 @@ public function manage_earnings_and_enrollments( string $order_status, int $orde $object_id = $item->id; // It could be course/bundle/plan id. if ( $this->order_model::TYPE_SINGLE_ORDER !== $order->order_type ) { $object_id = apply_filters( 'tutor_subscription_course_by_plan', $item->id, $order ); + + /** + * Do not process enrollment for membership plan. + * + * @since 3.2.0 + */ + $plan_info = apply_filters( 'tutor_checkout_plan_info', new \stdClass(), $object_id ); + if ( $plan_info && $plan_info->is_membership_plan ) { + continue; + } } $has_enrollment = tutor_utils()->is_enrolled( $object_id, $student_id, false );