Skip to content

Commit ae58d74

Browse files
authored
gpnf-gpeb-auto-attach-child-entries.php: Added snippet to Auto-attach Child Entries to Parent when Editing via GP Entry Blocks.
1 parent e320628 commit ae58d74

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* Gravity Perks // Nested Forms // Auto-attach Child Entries to Parent when Editing via GP Entry Blocks.
4+
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
5+
*
6+
* By default, when adding a new child entry to a Nested Form field while editing a parent entry via GP Entry Blocks, the
7+
* child entry is saved to the session and will not be attached to the parent entry unless you click "Update" on the
8+
* parent entry form.
9+
*
10+
* Use this snippet to automatically attach the child entry to the parent as soon as the child form is submitted.
11+
*/
12+
add_filter( 'gpnf_set_parent_entry_id', function( $parent_entry_id ) {
13+
if ( rgget( 'edit_entry' ) ) {
14+
$parent_entry_id = rgget( 'edit_entry' );
15+
}
16+
return $parent_entry_id;
17+
} );

0 commit comments

Comments
 (0)