Created
December 25, 2024 05:50
-
-
Save saifsultanc/4114e6cd18d7af721644c67c5bfc9f2b to your computer and use it in GitHub Desktop.
gcgs-process-feeds-partial-entry.php
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 | |
/** | |
* Gravity Perks // GP Google Sheets // Process Feed when Partial Entry is Saved. | |
* | |
* Process Google Sheet feeds when a partial entry is saved. | |
*/ | |
add_action( 'gform_partialentries_post_entry_saved', 'send_to_google_sheet_on_partial_entry_saved', 10, 2 ); | |
function send_to_google_sheet_on_partial_entry_saved( $partial_entry, $form ) { | |
if ( function_exists( 'gp_google_sheets' ) ) { | |
$partial_entry['status'] = 'partial'; | |
gc_google_sheets()->maybe_process_feed( $partial_entry, $form ); | |
gf_feed_processor()->save()->dispatch(); | |
} | |
} | |
add_filter( 'gform_entry_post_save', 'post_save', 10, 2 ); | |
function post_save( $entry, $form ) { | |
$feeds = GFAPI::get_feeds( null, $form['id'] ); | |
foreach( $feeds as $feed ) { | |
if ( rgar( $feed, 'addon_slug') == 'gp-google-sheets' ) { | |
gc_google_sheets()->process_feed( $feed, $entry, $form ); | |
} | |
} | |
return $entry; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment