LLMS_REST_Posts_Controller::delete_item_permissions_check( WP_REST_Request $request )

Check if a given request has access to delete an item.


Parameters Parameters

$request

(WP_REST_Request) (Required) Full details about the request.


Top ↑

Return Return

(bool|WP_Error)


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/abstracts/class-llms-rest-posts-controller.php

	public function delete_item_permissions_check( $request ) {

		$object = $this->get_object( (int) $request['id'] );
		if ( is_wp_error( $object ) ) {
			// LLMS_Post not found, we don't return a 404.
			if ( in_array( 'llms_rest_not_found', $object->get_error_codes(), true ) ) {
				return true;
			}

			return $object;
		}

		if ( ! $this->check_delete_permission( $object ) ) {
			return llms_rest_authorization_required_error(
				sprintf(
					// Translators: %s = The post type name.
					__( 'Sorry, you are not allowed to delete %s as this user.', 'lifterlms' ),
					get_post_type_object( $this->post_type )->labels->name
				)
			);
		}

		return true;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.18 Provide a more significant error message when trying to delete an item without permissions.
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.