Created
June 11, 2024 18:43
-
-
Save rafaehlers/ab507aed00ec171bc3f05db649962ed4 to your computer and use it in GitHub Desktop.
Trigger feeds after entry duplication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // DO NOT COPY THIS LINE | |
add_action( 'gravityview/duplicate-entry/duplicated', 'gk_run_stuff_after_duplication', 10, 2 ); | |
function gk_run_stuff_after_duplication($duplicated_entry, $entry){ | |
$form_id = $duplicated_entry['form_id']; | |
$form = GFAPI::get_form( $form_id ); | |
$run_on_forms = [92]; //The IDs of the Forms you'd like to affect. To target more forms, use [36,81,12] as an example | |
$feed = GFAPI::get_feed( 62 ); // replace 62 with the ID of the GP Google Sheets feed | |
if( !in_array( $form['id'], $run_on_forms ) ){ | |
return; | |
} | |
GFAPI::send_notifications( $form, $duplicated_entry ); | |
add_filter( 'gform_is_feed_asynchronous', '__return_false', 1294873 ); | |
$GoogleSheets = GP_Google_Sheets::get_instance(); | |
$GoogleSheets->process_feed( $feed, $duplicated_entry, $form ); | |
remove_filter( 'gform_is_feed_asynchronous', '__return_false', 1294873 ); | |
if( ! class_exists('Gravity_Flow_API') ) { | |
return; | |
} | |
add_filter( 'gform_is_feed_asynchronous', '__return_false', 1294873 ); | |
$api = new Gravity_Flow_API( $form['id'] ); | |
$api->restart_workflow( $duplicated_entry ); | |
remove_filter( 'gform_is_feed_asynchronous', '__return_false', 1294873 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment