gravityflow_step_status_webhook

Description

The gravityflow_step_status_webhook filter allow the step status for the outgoing webhook step to be modified before the step is complete. The initial value of the status for the filter is set based on the HTTP response code received from the webhook:

  • complete = Response Code 200 – 299
  • error_client = Response Code 400 – 499
  • error_server = Response Code 500 – 599
  • error = Any other response code

Parameters

ParameterTypeDetails
$step_statusStringThe step status derived from webhook response.
$responseArrayThe response returned from webhook.
$argsArrayThe arguments used for executing the webhook request.
$current_entryEntryThe current entry.
$current_stepStep The current step.

Examples

Treat 301 as a server error

add_filter( 'gravityflow_step_status_webhook', 'sh_filter_gravityflow_step_status_webhook', 10, 5 );
function sh_filter_gravityflow_step_status_webhook( $step_status, $response, $args, $current_entry, $current_step ) {
	if ( isset( $response['response']['code'] ) ) {
                $http_response_code = intval( $response['response']['code'] );
		//Treat a 301 (Moved Permanently) as a Server Error that you might notify admin for workflow step settings update.
		if( $http_response_code == 301 ) {
			$step_status = 'error_server';
		}
	}
	return $step_status;
}

You may want to add a filter to gravityflow_response_message_webhook in combination with this filter.

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?