GravityEdit: How to trigger feeds after editing an entry
The information below does not apply to form notifications. To send a form notification, please read: How to trigger form notifications when editing with GravityEdit.
To trigger a Gravity Forms add-on feed when editing an entry with GravityView, please check this article instead.
When you update a field value on GravityEdit, that action doesn't trigger the standard Gravity Forms "Entry Updated" action. That's because updating 10 fields for 10 entries could lead to 100 emails!
But sometimes you want to turn on Gravity Forms actions. To do that, GravityEdit has a filter: gravityview-inline-edit/remove-gf-update-hooks
, the default is true
.
To trigger Gravity Forms actions when updating fields, add this code:
add_filter( 'gravityview-inline-edit/remove-gf-update-hooks', '__return_false' );
Adding the code snippet above will once again trigger the following hooks:
gform_entry_pre_update
gform_form_pre_update_entry
gform_form_pre_update_entry_{$form_id}
gform_post_update_entry
gform_post_update_entry_{$form_id}
Before you use this code:
- If you are not sure how to add custom code to your theme, please take a look at this article.
- The code samples below target specific forms by their ID. In those examples, it's the ID 100. Please change that to the specific form ID connected to your View.
Trigger all feeds from a specific form
add_filter( 'gravityview-inline-edit/entry-updated', 'gravityedit_trigger_feeds', 10, 5 ); function gravityedit_trigger_feeds( $update_result, $entry = array(), $form_id = 0, $gf_field = null, $original_entry = array() ) { if ( 100 !== (int) $form_id ) { // replace 100 with your form ID return $update_result; } if( ! class_exists('GFAPI') ) { return; } $form = GFAPI::get_form( $form_id ); add_filter( 'gform_is_feed_asynchronous', '__return_false', 1294873 ); gf_apply_filters( array( 'gform_entry_post_save', $form['id'] ), $entry, $form ); remove_filter( 'gform_is_feed_asynchronous', '__return_false', 1294873 ); return $update_result; }
When using the MailChimp Add-On
add_filter( 'gravityview-inline-edit/entry-updated', 'gravityview_inline_edit_trigger_update_actions', 10, 5 ); function gravityview_inline_edit_trigger_update_actions( $update_result, $entry = array(), $form_id = 0, $gf_field = null, $original_entry = array() ) { if ( 100 !== (int) $form_id ) { // replace 100 with your form ID return $update_result; } if( ! class_exists('GFAPI') ) { return; } $form = GFAPI::get_form( $form_id ); if ( function_exists( 'gf_mailchimp' ) ) { add_filter( 'gform_is_feed_asynchronous', '__return_false', 1294873 ); gf_mailchimp()->maybe_process_feed( $entry, $form ); remove_filter( 'gform_is_feed_asynchronous', '__return_false', 1294873 ); } return $update_result; }
Priority is set to something unlikely to be used by other code (1294873). Feel free to use a different priority.