gravityflow_step_status_webhook

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

Example:

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 should be placed in the functions.php file of your active theme.