Last active
July 11, 2024 00:44
-
-
Save rafaehlers/90a5663b6af45fa661f70744e35638f1 to your computer and use it in GitHub Desktop.
Trigger workflow after duplicating an entry in GravityView
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 | |
if( !in_array( $form['id'], $run_on_forms ) ){ | |
return; | |
} | |
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