-
-
Save moxet/ce083e61e3c1e4de2c4df0d360b28e99 to your computer and use it in GitHub Desktop.
JetFormBuilder Do something on receiving webhook response
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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