Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save spivurno/f17b19b09425308b684e19ea6b77599a to your computer and use it in GitHub Desktop.
Save spivurno/f17b19b09425308b684e19ea6b77599a to your computer and use it in GitHub Desktop.
<?php
/**
* Gravity Perks // Nested Forms // Delay Child Notifications for Parent Payment
* http://gravitywiz.com/documentation/gravity-forms-nested-forms/
*/
add_filter( 'gpnf_should_send_notification', function( $should_send_notification, $notification, $context, $parent_form, $nested_form_field, $entry, $child_form ) {
if( $context == 'parent' ) {
$parent_entry = GFAPI::get_entry( rgar( $entry, 'gpnf_entry_parent' ) );
$should_send_notification = in_array( rgar( $parent_entry, 'payment_status' ), array( 'Paid', 'Active' ) );
}
return $should_send_notification;
}, 10, 7 );
add_action( 'gform_post_payment_completed', function( $entry ) {
if( is_callable( 'gpnf_notification_processing' ) ) {
gpnf_notification_processing()->maybe_send_child_notifications( $entry, GFAPI::get_form( $entry['form_id'] ) );
}
} );
@rochekaid
Copy link

Can this work if the gravity form is being used with Woocommerce?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment