Documentation Developers
Custom forms and hooks
Capture forms of your theme or your own code, and the actions and filters Leadwon offers.
Forms without a form plugin
Most forms need no code. Run the form scan under Leads → Forms and tick the form, or add a data-leadwon attribute to the form tag. Its value becomes the form name:
<form action="/send.php" method="post" data-leadwon="Quote request">
Leadwon then saves the submission in the background, with its source, without changing how the form works.
Capture from your own code
When your code processes a submission, pass it to Leadwon:
do_action(
'leadwon_capture',
'quote-form', // Form ID.
'Quote request', // Form name.
array(
array( 'label' => 'Name', 'type' => 'text', 'value' => $name ),
array( 'label' => 'Email', 'type' => 'email', 'value' => $email ),
array( 'label' => 'Phone', 'type' => 'tel', 'value' => $phone ),
array( 'label' => 'Message', 'type' => 'textarea', 'value' => $message ),
)
);
Call it during the request of the visitor who sent the form, so Leadwon can read the source from their cookie. Name, email address and phone number are found by the field types and labels.
Actions
| Hook | Arguments | When |
|---|---|---|
leadwon_lead_created |
$lead_id, $data |
After a lead is saved. |
leadwon_lead_status_changed |
$lead_id, $new_status, $old_status |
After a lead changed its status. |
leadwon_contact_click |
$event_id, $row |
After a click on a phone, WhatsApp, email or map link was counted. |
Filters
| Hook | Use |
|---|---|
leadwon_capture_submission |
Return false to skip a submission. Receives $capture, $plugin, $form_id and $fields. |
leadwon_lead_data |
Change the values of a lead before it is saved. Receives $data, $fields and $attribution. |
leadwon_webhook_payload |
Change what the webhook sends. |
leadwon_telegram_message |
Change the Telegram message (Telegram’s HTML subset). Receives $text and $lead. |
leadwon_load_tracker |
Return false to not load the tracking script on a request. |
leadwon_form_selector |
CSS selector of the forms captured without a form plugin. |
leadwon_capability |
Capability needed to see and manage leads. Default manage_options. |
For example, to let editors work with leads:
add_filter( 'leadwon_capability', function () {
return 'edit_others_posts';
} );
Notification emails of your form plugin
Add {leadwon_attribution} to the notification email of any form plugin to include where the lead came from. {leadwon_channel}, {leadwon_source} and {leadwon_campaign} insert single values.