Skip to content

Instantly share code, notes, and snippets.

@Crocoblock
Created September 25, 2023 15:00
Show Gist options
  • Select an option

  • Save Crocoblock/0ba6951f01d17f64d5436f1448dad1a7 to your computer and use it in GitHub Desktop.

Select an option

Save Crocoblock/0ba6951f01d17f64d5436f1448dad1a7 to your computer and use it in GitHub Desktop.
JetFormBuilder Do something on receiving webhook response
<?php
add_action( 'jet-form-builder/action/webhook/response', function( $response, $settings ) {
//get webhook url
$url = $settings['webhook_url'];
//check if we are using some specific endpoint
if ( false === strpos( $url, 'random-string/v1/generate' ) ) {
return;
}
//get response code
$response_code = wp_remote_retrieve_response_code( $response );
//check if response OK
if ( $response_code !== 200 ) {
return;
}
//get response body
$body = wp_remote_retrieve_body( $response );
if ( ! is_scalar( $body ) ) {
return;
}
//update form field 'arg' with received value
jet_fb_context()->update_request( $body, 'arg' );
}, 0, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment