Forked from spivurno/gp-nested-forms-delay-child-notifications-for-parent-payment.php
Created
June 23, 2020 15:04
-
-
Save dexit/757ab7750bde6221e6fc922dfae2e732 to your computer and use it in GitHub Desktop.
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 // 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'] ) ); | |
| } | |
| } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment