Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

LLMS_Meta_Box_Order_Enrollment::save_update_enrollment( int $post_id )

Update enrollment data based on posted values.


Parameters Parameters

$post_id

(int) (Required) WP_Post ID of the order.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/admin/post-types/meta-boxes/class.llms.meta.box.order.enrollment.php

	private function save_update_enrollment( $post_id ) {

		$old_status = llms_filter_input_sanitize_string( INPUT_POST, 'llms_student_old_enrollment_status' );
		$new_status = llms_filter_input_sanitize_string( INPUT_POST, 'llms_student_new_enrollment_status' );

		if ( ! $new_status || $old_status === $new_status ) {
			return;
		}

		$order = llms_get_post( $post_id );

		if ( 'enrolled' === $new_status ) {
			llms_enroll_student( $order->get( 'user_id' ), $order->get( 'product_id' ), 'order_' . $order->get( 'id' ) );
		} else {
			llms_unenroll_student( $order->get( 'user_id' ), $order->get( 'product_id' ), $new_status, 'any' );
		}

		$new_status_name = llms_get_enrollment_status_name( $new_status );

		if ( ! $old_status ) {

			$note = sprintf( __( 'Student enrollment status changed to %s.', 'lifterlms' ), $new_status_name );

		} else {

			// Translators: %1$s = old enrollment status; %2$s = new enrollment status.
			$note = sprintf( __( 'Student enrollment status changed from %1$s to %2$s', 'lifterlms' ), llms_get_enrollment_status_name( $old_status ), $new_status_name );

		}

		$order->add_note( $note, true );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.9.0 Stop using deprecated FILTER_SANITIZE_STRING.
3.33.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.