Connected Caldera Forms has three important hooks that you can use to work with partial entries or modify data.
The Hooks
- ACTION: cf_form_connector_sequence_started
- This action fires after the first form in the sequence is submitted, after the entry is created.
- This action exposes three variables (only 2 in version 1.1)
- $connected_form_id – The ID of connected form
- $entry_id The ID of entry
- $user_id The user identifier – cookie ID, user ID, or null
- Added in version 1.2
- See note about user ID below
- This hook was added in version 1.1
- ACTION: cf_form_connector_sequence_advanced
- This action fires after a form in the sequence is submitted, but is not the last form in sequence.
- This action exposes four variables:
- $connected_form_id – The ID of connected form
- $current_form_id The ID of the form in sequence that was just submitted
- $entry_id The ID of entry
- $sequence_data All progress and field value data for current sequence
- This hook was added in version 1.1
- FILTER: cf_form_connector_sequence_complete_pre_save
- This filter runs after the last form in the sequence is submitted and allows you to modify the final data to be saved for the entry.
- This filter allows you to modify an array of data. That array is keyed by field ID, with array values representing that field’s value.
- This filter also exposes two other variables:
- $form The configuration for connected form (array)
- $entry_id The ID of entry
- This hook was added in version 1.1
- FILTER: cf_form_connector_position_data
- This filter runs whenever the data that tracks the current user’s progress in a sequence is returned.
- Use extreme caution when using this to modify position data. It was mainly added to allow you to create links to form sequences, for particular users.
- This filter exposes two variables:
- $data The array of position data. May be empty.
- $user_id The user identifier – cookie ID, user ID, or null
- Added in version 1.2
- See note about user ID below
- FILTER: cf_form_connector_add_next_btn
- This filter is used to prevent a next form or submit button to your connected forms.
- If you return false with this filter, then there will be no way to advance or complete the form.
- Use this filter when you want to take people to a form that they intentionally can’t complete.
- Use this filter when you want to implement your own next or submit buttons.
- This filter exposes five variables:
- $use Should – button be added. True to add, false to not add. Boolean.
- $is_submit – Is button a submit button — IE Is this the end of sequence? Boolean.
- $new_form Configuration of form in sequence that is being loaded. Array
- $connected_form_id – ID of connected form sequence. String
- $progress – Progress data for current user. Array
- This filter was added in version 1.1.2
- Example code
- ACTION: cf_form_connector_prioritize_logged_out
- This filter runs when a user logs in and previously tracked progress is about to be written to user meta, and let’s you change if data tracked when this user was last logged in has a higher priority than data collected when not logged in or not.
- This filter exposes 3 variables.
- $prioritize_logged_out Return false to reverse default logic and prioritize logged in data over logged out data. Boolean.
- $process_record Previous progress data collected when user was logged out. Will be empty if this user has never used a connected form while logged in before. Array.
- $logged_in_tracking Previous progress data collected and saved for this user when they were logged in.Will be empty if this user has never used a connected form while logged out before. Array.
- This filter was added in version 1.2.2
A Note About User ID
cf_form_connector_sequence_started and cf_form_connector_position_data expose a $user_id variable. This variable is not always a WordPress user ID. $user_id can be one of three things:
- WordPress user ID – If the user was logged in while filling out the form, progress is tracked as user meta, and $user_id is the WordPress user ID.
- Unique ID – If the user was not logged in while filling out the form, a cookie (cfcfrm_usr) is used to track a unique ID for the user. The progress is stored in an option identified by that ID with the prefix “cfcfrm_”.
- null – If the current user is not logged in and no cookie is set, this value will be null.
Example Of Using These Hooks
Send An Email With A Link To Continue The Connected Forms Sequence
Where Does This Code Go?
When using WordPress hooks to customize Caldera Forms or other plugins you should not modify the plugin files, or you will lose your changes when you update the plugin. Instead you should create a small plugin to hold the custom code. It's easy, learn how here.
Technically you can add the custom code to your theme's functions.php, but then you will not be able to change your theme and keep these customizations.