Skip to content

Commit

Permalink
gpnf-gflow-delay-child-feed.php: Added snippet for GP Nested Forms …
Browse files Browse the repository at this point in the history
…to process Addon Feed for Nested Entry only after Parent Entry Workflow is Approved.
  • Loading branch information
saifsultanc committed Dec 15, 2023
1 parent b714121 commit 98440ce
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @todo
* - Make all parameters optional. Would allow this snippet to apply to any child feed for which a parent feed of the same type was present for any Gravity Flow step.
*/
class GW_GPNF_Addon_Delay_Child_Feed {
class GPNF_GFlow_Delay_Child_Feed {
public function __construct( $args = array() ) {

$this->_args = wp_parse_args( $args, array(
Expand All @@ -32,16 +32,15 @@ public function init() {
add_action( 'gravityflow_step_complete', array( $this, 'handle_gravityflow_step_completion' ), 10, 4 );
}

// Update 6 to the parent ID form and 4 to the Nested Form Field ID on the parent form
function addon_should_process( $should_process_feed, $feed, $context, $parent_form, $nested_form_field, $entry ) {
// disable immediate processing of GP Google Sheets feed for parent form 6's nested field ID 4.
// disable immediate processing of Addon Feed for the nested entries.
return false;
}

function handle_gravityflow_step_completion( $step_id, $entry_id, $form_id, $status ) {
// Update 6 to the GP Google Sheets Workflow Step on the Parent Form
// Update 6 to the Addon Workflow Step on the Parent Form
if ( $step_id == $this->_args['step_id'] && $status == 'complete' ) {
// When GP Google Sheets Workflow step is complete on Parent from
// When Addon Workflow step is complete on Parent from
$entry = GFAPI::get_entry( $entry_id );
$parent_form = GFAPI::get_form( $form_id );

Expand Down Expand Up @@ -74,7 +73,7 @@ function handle_gravityflow_step_completion( $step_id, $entry_id, $form_id, $sta
};


new GW_GPNF_Addon_Delay_Child_Feed( array(
new GPNF_GFlow_Delay_Child_Feed( array(
'form_id' => 6, // Set this to the parent form ID
'nested_field_id' => 4, // Set this to nested form field if (on parent form)
'step_id' => 6, // Set this to workflow step id on the feed (on parent form)
Expand Down

0 comments on commit 98440ce

Please sign in to comment.