WordPress filter hook · part of WordPress core
rest_pre_echo_response
A WordPress core filter that 6 plugins also fire themselves, running on 13K+ sites between them.
“This filter is documented in wp-includes/rest-api/class-wp-rest-server.php”
How to use rest_pre_echo_response
It's a filter: your callback receives the value and 2 more arguments, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'rest_pre_echo_response', function( $data, $server, $request ) {
// Change $data here.
return $data;
}, 10, 3 );Argument names come from Discount Rules for WooCommerce's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
This hook is fired by WordPress core too. Official reference on developer.wordpress.org →
6 plugins that fire rest_pre_echo_response
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
ووسلام7,000+ installs
apply_filters( 'rest_pre_echo_response', $server->response_to_data($result, false), $server, $request )includes/Services/MonitoringDiagnostics.php:37 -
Discount Rules for WooCommerce4,000+ installs
apply_filters( 'rest_pre_echo_response', $data, $server, $request )engine/OutputBuffer.php:103 -
MapSVG2,000+ installs
apply_filters( 'rest_pre_echo_response', $data, $server, $request )php/Integration/RestResponseJsonEncoder.php:17 -
WebToffee Universal Commerce Protocol Enabler for Woocommerce10+ installs
apply_filters( 'rest_pre_echo_response', $data, $server, $request )public/class-webtoffee-ucp-enabler-for-woocommerce-public.php:385 -
Live Visitor AnalyticsFewer than 10 installs
apply_filters( 'rest_pre_echo_response', $data, $server, $request )includes/class-pqanalytics-fast.php:205 -
Kibi FormsFewer than 10 installs
apply_filters( 'rest_pre_echo_response', $server->response_to_data( $response, $embed ), $server, $request )includes/class-delivery.php:114
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.