Forked from spivurno/gp-nested-forms-user-registration-map-full-child-entry-data.php
Created
January 25, 2022 21:17
-
-
Save andrenellin/17e7d0e0731af25465f1e399eadba3c3 to your computer and use it in GitHub Desktop.
Gravity Perks // GP Nested Forms // Map Full Child Entry Data via User Registration Add-on
This file contains 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 Nested Forms // Map Full Child Entry Data via User Registration Add-on | |
* http://gravitywiz.com/documentation/gravity-forms-nested-forms/ | |
*/ | |
add_action( 'gform_user_registration_meta_value', function( $value, $meta_key, $meta, $form, $entry, $is_username ) { | |
if( ! is_callable( 'gp_nested_forms' ) || ! gp_nested_forms()->has_nested_form_field( $form ) ) { | |
return $value; | |
} | |
foreach( $meta as $key => $_value ) { | |
if( $key != $meta_key ) { | |
continue; | |
} | |
$field = GFAPI::get_field( $form, $_value ); | |
if( ! $field || $field->get_input_type() != 'form' ) { | |
continue; | |
} | |
$_entry = new GPNF_Entry( $entry ); | |
$value = $_entry->get_child_entries( $field->id ); | |
} | |
return $value; | |
}, 10, 6 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment