Hooking into the Lead save/update process (3rd Party Development)

Hooks

inbound_store_lead_post

Function inbound_store_lead doubles as an ajax method and a traditional method for storing and updating lead profiles.

This method fires during a tracked form submit and is manually invoked by select extensions.

To perform additional actions after the lead has been created/update we can use the inbound_store_lead_post action hook.

Here’s an example where we hook into inbound_store_lead_post and use data related to a Lead being created/updated to perform additional operations:

inboundnow_form_submit_actions

inboundnow_form_submit_actions is ran during an Inbound Form submission and will not run on 3rd party tracked forms. Hooking into this action hook may provide better performance as it is ran after form validation and before redirection. It is not used in an ajax requests. This means you will be able to throw errors and create stop points during the submission process.

 

Differences

inbound_store_lead_post hook runs in an ajax call which makes it very difficult to troubleshoot. The only real way to troubleshoot this hook is to use error_log() commands and check the PHP error logs. This function is ran after a lead is created or updated in the leads database, which means it’s user¬†extends past Inbound Now Forms as some 3rd party extensions make use of this hook to add leads directly to the database.

inboundnow_form_submit_actions hook runs in sych with an inbound form submission. So methods hooked into it can interrupt the submission flow which is a lot better for testing. This function is run directly after an inbound form is submitted. 

Manually invoking inbound_store_lead()

There may be a point where you are looking to hook into a 3rd party plugin to retrieve information during a registration process and use that information to create/update a lead profile. Here’s an example from our BuddyPress extension where we have hooked into the BuddyPress registration process, retrieved the user information we needed to create a lead, and used that information to add the lead by invoking inbound_store_lead():