Skip to content
Docs
Get RestroPress

Filter

rpress_validate_slot

Updated
On this page

Filters the result of the service slot availability check.

Runs in the check_service_slot AJAX handler after the rpress_check_service_slot filter has processed the sanitized POST data. Return a WP_Error to send an error response with its message, an array to send it as the JSON response, or any other value, which is treated as success when non-empty and error when empty. The cart totals payload is merged into the response afterwards.

Parameters#

ParameterTypeDescription
$responsemixedResult of the rpress_check_service_slot filter. By default this is the sanitized POST data array.

Return value#

array|WP_Error|mixed. A WP_Error to report a failure, an array to use as the JSON response, or a value treated as a success/error flag.

Example#

function my_validate_slot( $response ) {
	if ( is_array( $response ) && empty( $response['rpress_service_time'] ) ) {
		return new WP_Error( 'no_slot', __( 'Please choose a time slot.', 'my-plugin' ) );
	}
	return $response;
}
add_filter( 'rpress_validate_slot', 'my_validate_slot' );

Notes#

Because the default input is the POST data, an array returned unchanged is sent back to the browser as the response body.

Source#

Applied in:

  • includes/class-rpress-ajax.php (line 820), in RP_AJAX::check_service_slot()

See also#

Was this page helpful?