Last active
July 29, 2020 06:50
-
-
Save zackkatz/e25cddf3abe9edc856f5ec83df1a4ec7 to your computer and use it in GitHub Desktop.
GravityView - Clears results cache after running Gravity Flow workflow
This file contains 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 | |
// Add the code below to your functions.php file. Will be included in GravityView 2.9 release. | |
add_action( 'gravityflow_post_process_workflow', 'gv_clear_cache_after_workflow', 10, 4 ); | |
/** | |
* Clears GravityView entry cache after running a Gravity Flow Workflow | |
* | |
* Thanks to @CodenomadIndia for improved code! | |
* | |
* @param array $form | |
* @param int $entry_id | |
* @param int $step_id | |
* @param int $starting_step_id | |
* | |
* @return void | |
*/ | |
public function gv_clear_cache_after_workflow( $form, $entry_id, $step_id, $starting_step_id ) { | |
$step = gravity_flow()->get_step( $step_id ); | |
// Check if the step type is updating an entry | |
if( ! $step || 'update_entry' !== $step->get_type() ) { | |
return; | |
} | |
// Clear cache of the step target's form id | |
do_action( 'gravityview_clear_form_cache', $step->target_form_id ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @zackkatz