Documentation Developers

Custom forms and hooks

Capture forms of your theme or your own code, and the actions and filters Dealroot 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-dealroot attribute to the form tag. Its value becomes the form name:

<form action="/send.php" method="post" data-dealroot="Quote request">

Dealroot 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 Dealroot:

do_action(
	'dealroot_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 Dealroot 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
dealroot_lead_created $lead_id, $data After a lead is saved.
dealroot_lead_status_changed $lead_id, $new_status, $old_status After a lead changed its status.
dealroot_contact_click $event_id, $row After a click on a phone, WhatsApp, email or map link was counted.

Filters

Hook Use
dealroot_capture_submission Return false to skip a submission. Receives $capture, $plugin, $form_id and $fields.
dealroot_lead_data Change the values of a lead before it is saved. Receives $data, $fields and $attribution.
dealroot_webhook_payload Change what the webhook sends.
dealroot_telegram_message Change the Telegram message (Telegram’s HTML subset). Receives $text and $lead.
dealroot_load_tracker Return false to not load the tracking script on a request.
dealroot_form_selector CSS selector of the forms captured without a form plugin.
dealroot_capability Capability needed to see and manage leads. Default manage_options.

For example, to let editors work with leads:

add_filter( 'dealroot_capability', function () {
	return 'edit_others_posts';
} );

Notification emails of your form plugin

Add {dealroot_attribution} to the notification email of any form plugin to include where the lead came from. {dealroot_channel}, {dealroot_source} and {dealroot_campaign} insert single values.