Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save spivurno/e600cba330ac540722cdbc48a38badf5 to your computer and use it in GitHub Desktop.

Select an option

Save spivurno/e600cba330ac540722cdbc48a38badf5 to your computer and use it in GitHub Desktop.
<?php
/**
* Gravity Perks // Nested Forms // Copy Parent Entry Properties on Parent Form Submission
* http://gravitywiz.com/documentation/gravity-forms-nested-forms/
*/
// Update "123" to your parent form ID.
add_action( 'gform_entry_created_123', function( $entry, $form ) {
// Specify which properties you would like to populate from the parent.
// Supports: id, form_id, post_id, date_created, is_starred, is_read, ip, source_url, user_agent, currency, payment_status, payment_date, payment_amount, payment_method, transaction_id, is_fulfilled, created_by, transaction_type, status, date_updated, last_payment_date
$copy_from_parent = array( 'transaction_id', 'payment_date', 'payment_status' );
// Specify the field ID of the Nested Form field on your parent form.
$nested_form_field_id = 1;
$child_entry_ids = explode( ',', rgar( $entry, $nested_form_field_id ) );
foreach( $child_entry_ids as $child_entry_id ) {
foreach( $copy_from_parent as $parent_property ) {
GFAPI::update_entry_property( $child_entry_id, $parent_property, $entry[ $parent_property ] );
}
}
} );
@SerpikoIT
Copy link
Copy Markdown

is this page still valid ??? if so how could i use it?

@spivurno
Copy link
Copy Markdown
Author

@SerpikoIT I haven't tested this since I originally wrote it, but it appears functional. To use this, copy and paste the snippet into your theme's functions.php file and update the form and field IDs as indicated via the inline comments.

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