LLMS_REST_Users_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/abstracts/class-llms-rest-users-controller.php

	 * Delete the object
	 *
	 * 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!
	 *
	 * @since 1.0.0-beta.1
	 *
	 * @param obj             $object  Instance of the object from `$this->get_object()`.
	 * @param WP_REST_Request $request Request object.
	 * @return true|WP_Error `true` when the object is removed, `WP_Error` on failure.
	 */
	protected function delete_object( $object, $request ) {

		$id       = $object->get( 'id' );
		$reassign = 0 === $request['reassign'] ? null : $request['reassign'];

		if ( ! empty( $reassign ) ) {
			if ( $reassign === $id || ! get_userdata( $reassign ) ) {
				return llms_rest_bad_request_error( __( 'Invalid user ID for reassignment.', 'lifterlms' ) );
			}
		}

		// Include admin user functions to get access to `wp_delete_user()`.


Top ↑

Changelog Changelog

Changelog
Version Description
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.