I am using gravity form. I have a webhook to create a lead on my CRM. I have successfully done that. But I need to create another entity on CRM. in order to create that entity I need the id that lead just create through webhook. API returns lead information. here is the response look likes :
2024-05-10 20:26:25.959583 - DEBUG --> GF_Webhooks::process_feed(): Webhook successfully executed. code: 200; body: {"id":"663e2e91dd14cd70c","name":"example name","deleted":false,"firstName":"why lead id is not working","status":"Free Trial Received","source":"Website","industry":null,"website":"hluluasd.com","emailAddress":"leadid@gmail.com","doNotCall":false,"createdAt":"2024-05-10 14:26:25","modifiedAt":"2024-05-10 14:26:25","targetListIsOptedOut":false,"country":"Other","leadType":"Photographer","leadPriority":"High","collectedFrom":"Google Map","companySize":"1-10","timeZone":"Est","emailAddressIsOptedOut":false,"emailAddressIsInvalid":false,"phoneNumberIsOptedOut":false,"phoneNumberIsInvalid":false,"emailAddressData":[{"emailAddress":"leadid@gmail.com","lower":"leadid@gmail.com","primary":true,"optOut":false,"invalid":false}],"phoneNumberData":[],"createdById":"6638bdf8d528b68c3","assignedUserId":"639af1ec711c3e701","assignedUserName":"Minhajur Rahman","teamsIds":[],"teamsNames":{},"isFollowed":false}
2024-05-10 20:26:25.960020 - DEBUG --> GF_Feed_Processor::task(): Marking entry #88 as fulfilled for gravityformswebhooks
I have grab this from logging from gravity forms. I want to use this data and tigger another webhook request. I have tried gform_webhooks_post_request and this is the code in functions.php :
add_action( 'gform_webhooks_post_request', 'capture_lead_id', 10, 4 );
function capture_lead_id( $response, $feed, $entry, $form ) {
// Log the entire response to the server for debugging
error_log( 'Webhook Response: ' . print_r( $response, true ) );
// Check if the response is successful
if ( ! is_wp_error( $response ) ) {
// Extract lead ID from the response
$lead_id = isset( $response['id'] ) ? $response['id'] : '';
// Log the lead ID to the server
error_log( 'Lead ID: ' . $lead_id );
}
}
I can’t grab the lead ID. it is empty