I recommend adding a statement right inside your function to ensure it’s running. Then add a statement any time you assign a value to a variable, and log the return value from any function call you make. Try something like this:
add_action( 'gform_webhooks_post_request_8', function ( $response, $feed, $entry, $form ) {
GFCommon::log_debug( current_action() . '(): running.' );
GFCommon::log_debug( current_action() . '(): My Response => ' . print_r( $response, true ) );
if ( ! is_wp_error( $response ) ) {
GFCommon::log_debug( current_action() . '(): My Entry => ' . print_r( $entry, true ) );
#GFAPI::delete_entry( $entry['id'] );
$form_id = "9";
GFCommon::log_debug( current_action() . '(): My Form ID => ' . print_r( $form_id, true ) );
$person_id = $response["person"]["id"];
GFCommon::log_debug( current_action() . '(): My Person ID => ' . print_r( $person_id, true ) );
$result = GFAPI::submit_form( $form_id , $person_id );
GFCommon::log_debug( current_action() . '(): My Result => ' . print_r( $result, true ) );
}
}, 10, 4 );
With that revised code and Gravity Forms logging enabled, test your form, then check the Gravity Forms Core log and search for the statements that begin "My ". Let us know what you find out!
This is how I am trying to grab person_id, but is not working:
$person_id = $body[“person”][“id”];
2023-04-10 18:08:36.933114 - DEBUG → gform_webhooks_post_request_8(): My Form ID => 9 2023-04-10 18:08:36.933171 - DEBUG → gform_webhooks_post_request_8(): My Person ID =>
You also need to make sure you are passing the correct values to GFAPI::submit_form(). If you check the following page of the documentation, you’ll find the second arg should be an array of input values, not just your person id.
Glad to read that you found a fully functional solution with the code snippets.
For others following along that might like to do the same without requiring any code:
Gravity Flow’s Outgoing Webhook step type provides the ability to map response values from JSON through step settings. From the snippet above, putting person\id into the setting would store it into a separate field.