send Bricks Builder form submissions to a Pabbly webhook in WordPress, with a ready-to-use code snippet and example demo data for easy testing
add_action('bricks/form/custom_action', 'send_form_to_pabbly_webhook', 10, 1);
function send_form_to_pabbly_webhook($form) {
$fields = $form->get_fields();
$form_id = $fields['formId'];
// Ensure the action only runs for the specified form
if ($form_id !== 'YOUR_FORM_ID_HERE') {
return;
}
// Map your form fields using their IDs, using example/demo data
$payload = [
// Add Each Field Name the names can be custom and Match form Field IDs Exactly
'DataFirstname' => sanitize_text_field($fields['form-field-hlypqd'] ?? ''),
'DataLastname' => sanitize_text_field($fields['form-field-btmhex'] ?? ''),
'DataEmail' => sanitize_email($fields['form-field-xrljaf'] ?? ''),
'DataCompany' => sanitize_text_field($fields['form-field-eppfrx'] ?? ''),
'date' => sanitize_text_field($fields['form-field-ximsmj'] ?? ''),
'staticfield' => 'static value if you need you can add it too',
];
// Connect Trigger > Webhook by Pabbly > Catch Webhook (Hooks works same too)
$webhook_url = 'https://connect.pabbly.com/workflow/sendwebhookdata/rand234g23';
$response = wp_remote_post($webhook_url, [
'headers' => ['Content-Type' => 'application/json'],
'body' => wp_json_encode($payload),
'timeout' => 15,
]);
if (is_wp_error($response)) {
$form->set_result([
'action' => 'send_form_to_pabbly_webhook',
'type' => 'error',
'message' => esc_html__('Failed to send form.', 'bricks'),
]);
} else {
$form->set_result([
'action' => 'send_form_to_pabbly_webhook',
'type' => 'success',
'message' => esc_html__('Form successfully sent.', 'bricks'),
]);
}
}