Using post ID to get ACF field for custom webhook in an Elementor Form. Whats my issue?

I can’t figure out what I’m doing wrong, I’ve been able to pull the webhook from a hidden field into this but that seems super not very secure as I can see the webhooks URL. Any insight would be greatly appreciated. Here is my code so far:

add_action( ‘elementor_pro/forms/new_record’, function( $record, $handler ) {

$form_name = $record->get_form_settings( ‘form_name’ );

if ( ‘Defaultlp’ !== $form_name ) {
return;
}

$raw_fields = $record->get( ‘fields’ );
$fields = [];
foreach ( $raw_fields as $id => $field ) {
$fields[ $id ] = $field[‘value’];
}

// Get ACF Submitted Webhook
global $post;
$id = $post->ID;
$lppost = get_field(‘webhook_url’, $id );

// Send to Zapier
wp_remote_post( $lppost, [
‘body’ => $fields,
]);
}, 10, 2 );

Read more here:: Using post ID to get ACF field for custom webhook in an Elementor Form. Whats my issue?

Leave a Reply

Your email address will not be published. Required fields are marked *