Description
Perform a custom action when the partial entry has been saved or updated.
Usage
Entry Saved
The following would run for all forms with the partial entries feature enabled when the entry_saved event occurs.
add_action( 'gform_partialentries_post_entry_saved', 'your_function_name', 10, 2 );
Entry Updated
The following would run for all forms with the partial entries feature enabled when the entry_updated event occurs.
add_action( 'gform_partialentries_post_entry_updated', 'your_function_name', 10, 2 );
Parameters
- $partial_entry Entry Object
The partial entry object.
- $form Form Object
The current form object.
Examples
Trigger Mailchimp Feeds
This example shows how you can send partial entries to Mailchimp. You’ll also need to use the gform_allow_async_feed_reprocessing filter, so the feeds will be reprocessed on form submission.
add_action( 'gform_partialentries_post_entry_saved', 'send_to_mailchimp_on_partial_entry_save', 10, 2 );
add_action( 'gform_partialentries_post_entry_updated', 'send_to_mailchimp_on_partial_entry_save', 10, 2 );
function send_to_mailchimp_on_partial_entry_save( $partial_entry, $form ) {
$partial_entry['status'] = 'partial';
GFAPI::maybe_process_feeds( $partial_entry, $form, 'gravityformsmailchimp' );
}
Trigger Webhooks Feeds
This example shows how you can trigger Webhooks feeds for partial entries. You’ll also need to use the gform_allow_async_feed_reprocessing filter, so the feeds will be reprocessed on form submission.
add_action( 'gform_partialentries_post_entry_saved', 'webhooks_on_partial_entry_save', 10, 2 );
add_action( 'gform_partialentries_post_entry_updated', 'webhooks_on_partial_entry_save', 10, 2 );
function webhooks_on_partial_entry_save( $partial_entry, $form ) {
$partial_entry['status'] = 'partial';
GFAPI::maybe_process_feeds( $partial_entry, $form, 'gravityformswebhooks' );
}
Trigger Zapier Feeds
This example shows how you can send partial entries to Zapier. You’ll also need to use the gform_allow_async_feed_reprocessing filter, so the feeds will be reprocessed on form submission.
add_action( 'gform_partialentries_post_entry_saved', 'send_to_zapier_on_partial_entry_save', 10, 2 );
add_action( 'gform_partialentries_post_entry_updated', 'send_to_zapier_on_partial_entry_save', 10, 2 );
function send_to_zapier_on_partial_entry_save( $partial_entry, $form ) {
$partial_entry['status'] = 'partial';
GFAPI::maybe_process_feeds( $partial_entry, $form, 'gravityformszapier' );
}
Trigger HubSpot Feeds
This example shows how you can trigger HubSpot feeds for partial entries. You’ll also need to use the gform_allow_async_feed_reprocessing filter, so the feeds will be reprocessed on form submission.
add_action( 'gform_partialentries_post_entry_saved', 'send_to_hubspot_on_partial_entry_save', 10, 2 );
add_action( 'gform_partialentries_post_entry_updated', 'send_to_hubspot_on_partial_entry_save', 10, 2 );
function send_to_hubspot_on_partial_entry_save( $partial_entry, $form ) {
$partial_entry['status'] = 'partial';
GFAPI::maybe_process_feeds( $partial_entry, $form, 'gravityformshubspot' );
}
Add validation errors entry note
The following shows how you can add a note to the partial entry when it fails validation when using the next or submit buttons. The note can be viewed on the Entry Detail page in the Entries area of the form.
add_action( 'gform_partialentries_post_entry_updated', function ( $partial_entry, $form ) {
if ( wp_doing_ajax() && rgpost( 'action' ) == 'heartbeat' ) {
return;
}
$submission = GFFormDisplay::$submission[ (int) rgar( $form, 'id' ) ];
if ( rgar( $submission, 'is_valid' ) ) {
return;
}
$note = sprintf( 'Form (page %d) failed validation.<br>', rgar( $submission, 'page_number' ) );
$errors = GFFormDisplay::get_validation_errors( $form, array() );
foreach ( $errors as $error ) {
$field_selector = explode( '_', rgar( $error, 'field_selector' ) );
$field_id = end( $field_selector );
$note .= sprintf( '<br>%s (ID: %d): %s', rgar( $error, 'field_label' ), $field_id, rgar( $error, 'message' ) );
}
$user = wp_get_current_user();
$user_id = $user->ID ?: 0;
$user_name = $user->display_name ?: 'Unknown User';
GFAPI::add_note( rgar( $partial_entry, 'id' ), $user_id, $user_name, $note, 'validation', 'error' );
}, 10, 2 );
Since
This hook was added in version 1.0-beta-2.3.
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This action hook is located in GF_Partial_Entries::maybe_save_partial_entry() in class-gf-partial-entries.php.