Skip to content

Commit

Permalink
~ Fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
saifsultanc committed Jan 11, 2025
1 parent 2322a3c commit 3c47079
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Gravity Perks // Nested Forms // Set Created By Propery on Child Entries After User Account Registration.
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
*
* Set the created by property of the child entries that is embedded on a user registration form
* Set the created by property of the child entries that is embedded on a user registration form
* with the user id of the account that is created after the parent form is submittted.
*
* Instructions:
Expand All @@ -12,16 +12,16 @@
*/
add_action( 'gform_user_registered', 'add_created_by_property', 10, 4 );
function add_created_by_property( $user_id, $feed, $entry, $user_pass ) {
// Update '123' with the Id of the form.
if ( $entry['form_id'] !== '123' ){
return;
}

$parent_entry = new GPNF_Entry( $entry );
$child_entries = $parent_entry->get_child_entries();
// Update '123' with the Id of the form.
if ( $entry['form_id'] !== '123' ) {
return;
}

foreach ( $child_entries as $child_entry ) {
GFAPI::update_entry_property( $child_entry['id'], 'created_by', $user_id );
$child_entry['created_by'] = $user_id;
}
$parent_entry = new GPNF_Entry( $entry );
$child_entries = $parent_entry->get_child_entries();

foreach ( $child_entries as $child_entry ) {
GFAPI::update_entry_property( $child_entry['id'], 'created_by', $user_id );
$child_entry['created_by'] = $user_id;
}
}

0 comments on commit 3c47079

Please sign in to comment.