#Overview
This filter is run when WP Fusion is processing a form submission from one of our supported form plugins.
It is triggered after the initial contact ID lookup in the CRM, but before any data has been synced. It can be used to modify the data that’s sent to the CRM.
To use the code examples below, add them to your active theme’s functions.php file.
#Alternate filters
For more precise targeting there are two alternate filters with the same arguments:
wpf_{integration slug}_pre_submission
: Where{integration_slug}
is the name of the form integration, for examplewpf_gform_apply_tags
#Parameters
$update_data
(array): This is an array of data that will be synced to the CRM$user_id
(int): The user who submitted the form,0
if a guest$contact_id
(string): The ID of the contact record created / updated by the form submission$form_id
(int): The ID of the submitted form
#Examples
#Append to a field instead of overwriting it
In this case, we have a form field mapped to the ContactNotes
field in Infusionsoft, but instead of replacing the notes, we’d like to update them.
This example runs when a form is submitted and first loads the contact’s ContactNotes
from Infusionsoft. If there are already notes on the contact record, the new notes are appended to the existing notes before being sent back to the CRM.
function append_to_notes_field( $update_data, $user_id, $contact_id, $form_id ) { if ( ! empty( $update_data['ContactNotes'] ) && false !== $contact_id ) { // If we're updating an existing contact and there are notes in the data wp_fusion()->crm->connect(); // Set up the Infusionsoft API $result = wp_fusion()->crm->app->loadCon( $contact_id, array( 'ContactNotes' ) ); // Load the contact if ( ! is_wp_error( $result ) && ! empty( $result['ContactNotes'] ) ) { // Append the new notes to the existing notes (PHP_EOL adds a line break) $update_data['ContactNotes'] = $result['ContactNotes'] . PHP_EOL . $update_data['ContactNotes']; } } return $update_data; } add_filter( 'wpf_forms_pre_submission', 'append_to_notes_field', 10, 4 );