LLMS_REST_Enrollments_Controller::handle_creation_date_update( integer $student_id, integer $post_id, string $date )

Handles the enrollment creation date.

Parameters Parameters


(integer) (Required) Student id.


(integer) (Required) The post id.


(string) (Required) Creation date.

Top ↑

Return Return


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/server/class-llms-rest-enrollments-controller.php

	protected function handle_creation_date_update( $student_id, $post_id, $date ) {

		$date_created = rest_parse_date( $date );

		if ( ! $date_created ) {
			return llms_rest_bad_request_error();

		$date_created = date_i18n( 'Y-m-d H:i:s', $date_created );

		global $wpdb;

		$inner_query = $wpdb->prepare(
			SELECT upm2.meta_id
			FROM ( SELECT * FROM {$wpdb->prefix}lifterlms_user_postmeta ) AS upm2
			WHERE upm2.meta_key = '_start_date' AND upm2.user_id = %d AND upm2.post_id = %d
			ORDER BY upm2.updated_date DESC
			LIMIT 1

		$result = $wpdb->query(
				"UPDATE {$wpdb->prefix}lifterlms_user_postmeta SET updated_date = %s WHERE meta_id = (${inner_query});",
		); // no-cache ok.

		return $result;

Top ↑

Changelog Changelog

Version Description
1.0.0-beta.4 Fixed call to undefined function llms_bad_request_error(), must be llms_rest_bad_request_error().
1.0.0-beta.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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