LLMS_Post_Relationships::rest_filter_products_with_active_subscriptions_error_message( WP_REST_Response|WP_HTTP_Response|WP_Error|mixed $response, array $handler, WP_REST_Request $request )

Filter the error message returned when trying to delete a product with active subscription via REST API.

Description Description

The original message is a standard permission denied message.

Top ↑

Parameters Parameters


(WP_REST_Response|WP_HTTP_Response|WP_Error|mixed) (Required) Result to send to the client. Usually a WP_REST_Response or WP_Error.


(array) (Required) Route handler used for the request.


(WP_REST_Request) (Required) Request used to generate the response.

Top ↑

Return Return


Top ↑

Source Source

File: includes/class.llms.post.relationships.php

	public static function rest_filter_products_with_active_subscriptions_error_message( $response, $handler, $request ) {

		if ( is_wp_error( $response ) ) {
			foreach ( $response->errors as $code => &$data ) {
				// Error code can be produced by our rest-api or by wp core.
				if ( in_array( $code, array( 'llms_rest_cannot_delete', 'rest_cannot_delete' ), true ) ) {
					$data[0] = self::delete_product_with_active_subscriptions_error_message( $request['id'] );

		return $response;


Top ↑

Changelog Changelog

Version Description
5.4.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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