Skip to content
Docs
Get RestroPress

Action

rpress_api_output_before

Updated
On this page

Fires before the API response is rendered.

Runs in RPRESS_API::output() right after the HTTP status header is sent and before the response body is produced in the chosen format. Use it to send extra headers or to inspect the data about to be output.

Parameters#

ParameterTypeDescription
$arg1arrayThe response data about to be output.
$thisRPRESS_APIThe API instance.
$formatstringThe resolved output format.

Example#

function my_api_before_output( $data, $api, $format ) {
	if ( 'json' === $format ) {
		header( 'X-My-Api-Version: 1' );
	}
}
add_action( 'rpress_api_output_before', 'my_api_before_output', 10, 3 );

Source#

Fired from:

  • includes/api/class-rpress-api.php (line 1504), in RPRESS_API::output()
  • includes/class-rpress-api.php (line 1108), in RPRESS_API::output()

See also#

Was this page helpful?