Skip to content

Commit

Permalink
gpnf-process-gpgs-feed-on-nested-after-parent-workflow-complete.php
Browse files Browse the repository at this point in the history
…: Added snippet for GP Nested Forms to process GPGS on nested only after parent workflow is approved.
  • Loading branch information
saifsultanc committed Dec 9, 2023
1 parent 7d2c18d commit 4aad9de
Showing 1 changed file with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* Gravity Perks // Nested Forms // Post-specific Sessions
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
*
* Make Nested Forms sessions specific to the post on which the form is rendered by appending the current post ID.
*/
// Update 6 to the parent ID form and 4 to the Nested Form Field ID on the parent form
add_filter( 'gpnf_should_process_gp-google-sheets_feed_6_4', 'gpgs_should_process', 10, 6 );
function gpgs_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.
return false;
}

add_action( 'gravityflow_step_complete', 'processed_nested_entries_google_sheets_feed', 10, 4 );
function processed_nested_entries_google_sheets_feed( $step_id, $entry_id, $form_id, $status ) {
// Update 6 to the GP Google Sheets Workflow Step on the Parent Form
if ( $step_id == '6' && $status == 'complete' ) {
// When GP Google Sheets Workflow step is complete on Parent from
$entry = GFAPI::get_entry( $entry_id );

Check warning on line 20 in gp-nested-forms/gpnf-process-gpgs-feed-on-nested-after-parent-workflow-complete.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space
$parent_form = GFAPI::get_form( $form_id );

Check failure on line 22 in gp-nested-forms/gpnf-process-gpgs-feed-on-nested-after-parent-workflow-complete.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Whitespace found at end of line
// get all nested entries
$nested_entries = array();
foreach ( $parent_form['fields'] as $field ) {
if ( $field instanceof GP_Field_Nested_Form ) {
$_entries = explode( ',', $entry[ $field->id ] );

Check warning on line 27 in gp-nested-forms/gpnf-process-gpgs-feed-on-nested-after-parent-workflow-complete.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space
$nested_entries = array_merge( $nested_entries, $_entries );

Check warning on line 28 in gp-nested-forms/gpnf-process-gpgs-feed-on-nested-after-parent-workflow-complete.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Equals sign not aligned with surrounding assignments; expected 1 space but found 2 spaces
}
}
$nested_entries = array_unique( $nested_entries );

// process each nested entry
foreach( $nested_entries as $nested_entry_id ) {

Check failure on line 34 in gp-nested-forms/gpnf-process-gpgs-feed-on-nested-after-parent-workflow-complete.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Expected 1 space(s) after FOREACH keyword; 0 found

Check failure on line 34 in gp-nested-forms/gpnf-process-gpgs-feed-on-nested-after-parent-workflow-complete.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Space after opening control structure is required

Check failure on line 34 in gp-nested-forms/gpnf-process-gpgs-feed-on-nested-after-parent-workflow-complete.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

No space before opening parenthesis is prohibited

Check failure on line 34 in gp-nested-forms/gpnf-process-gpgs-feed-on-nested-after-parent-workflow-complete.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Expected exactly one space between closing parenthesis and opening control structure; &quot; &quot; found.

Check failure on line 34 in gp-nested-forms/gpnf-process-gpgs-feed-on-nested-after-parent-workflow-complete.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Expected 1 space(s) after closing parenthesis; found 2
$nested_entry = GFAPI::get_entry( $nested_entry_id );
if ( empty( $nested_entry_id ) || empty( $nested_entry ) || is_wp_error( $nested_entry ) ) {
continue;
}

$feeds = gp_google_sheets()->get_active_feeds( $nested_entry['form_id'] );
if ( empty( $feeds ) ) {
return;
}

// process feeds
foreach ( $feeds as $feed ) {
if ( rgar( $feed, 'addon_slug') !== 'gp-google-sheets' ) {

Check failure on line 47 in gp-nested-forms/gpnf-process-gpgs-feed-on-nested-after-parent-workflow-complete.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Expected 1 spaces before closing parenthesis; 0 found
continue;
}
//process the google sheets feed for the nested entry
gp_google_sheets()->process_feed( $feed, $nested_entry, GFAPI::get_form( $nested_entry['form_id'] ) );
}
}
}

Check failure on line 54 in gp-nested-forms/gpnf-process-gpgs-feed-on-nested-after-parent-workflow-complete.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Tabs must be used to indent lines; spaces are not allowed
}

0 comments on commit 4aad9de

Please sign in to comment.