LLMS_REST_Students_Progress_Controller::delete_object( obj $object, WP_REST_Request $request )

Delete the object.


Description Description

Note: we do not return 404s when the resource to delete cannot be found. We assume it’s already been deleted and respond with 204. Errors returned by this method should be any error other than a 404!


Top ↑

Parameters Parameters

$object

(obj) (Required) Instance of the object from $this->get_object().

$request

(WP_REST_Request) (Required) Request object.


Top ↑

Return Return

(true|WP_Error) true when the object is removed, WP_Error on failure.


Top ↑

Source Source

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

	protected function delete_object( $object, $request ) {

		$post = llms_get_post( $request['post_id'] );
		$ids  = 'lesson' === $post->get( 'type' ) ? array( $post->get( 'id' ) ) : $post->get_lessons( 'ids' );

		if ( $ids ) {
			foreach ( $ids as $id ) {
				llms_bulk_delete_user_postmeta(
					$request['id'],
					$id,
					array(
						'_is_complete'        => null,
						'_completion_trigger' => null,
					)
				);

			}
		}

		if ( 'lesson' !== $post->get( 'type' ) ) {
			llms_mark_incomplete( $request['id'], $post->get( 'id' ), $post->get( 'type' ) );
		}

		return true;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.13 Fixed student/lesson post meta key to delete, _is_complete in place of _status.
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.