Skip to content

Commit

Permalink
`gpnf-set-created-by-property-on-child-entries-after-user-registratio…
Browse files Browse the repository at this point in the history
…n.php` : Added new snippet for GP Nested Forms that sets the created by property on the child entries after user account is created.
  • Loading branch information
sbassah authored Sep 30, 2024
1 parent d0b75a5 commit 23bf3d1
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* 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

Check failure on line 6 in gp-nested-forms/gpnf-set-created-by-property-on-child-entries-after-user-registration.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Whitespace found at end of line
* with the user id of the account that is created after the parent form is submittted.
*
* Instructions:
* 1. Install per https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
* 2. Configure the snippet based on inline instructions.
*/
add_action( 'gform_user_registered', 'add_custom_user_meta', 10, 4 );
function add_custom_user_meta( $user_id, $feed, $entry, $user_pass ) {
// Update '123' with the Id of the form.

Check failure on line 15 in gp-nested-forms/gpnf-set-created-by-property-on-child-entries-after-user-registration.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Tabs must be used to indent lines; spaces are not allowed
if ( $entry['form_id'] !== '123' ){

Check failure on line 16 in gp-nested-forms/gpnf-set-created-by-property-on-child-entries-after-user-registration.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Tabs must be used to indent lines; spaces are not allowed

Check failure on line 16 in gp-nested-forms/gpnf-set-created-by-property-on-child-entries-after-user-registration.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Expected 1 space(s) after closing parenthesis; found 0

Check failure on line 16 in gp-nested-forms/gpnf-set-created-by-property-on-child-entries-after-user-registration.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Space between opening control structure and closing parenthesis is required
return;

Check failure on line 17 in gp-nested-forms/gpnf-set-created-by-property-on-child-entries-after-user-registration.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Tabs must be used to indent lines; spaces are not allowed
}

Check failure on line 18 in gp-nested-forms/gpnf-set-created-by-property-on-child-entries-after-user-registration.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Tabs must be used to indent lines; spaces are not allowed

Check failure on line 19 in gp-nested-forms/gpnf-set-created-by-property-on-child-entries-after-user-registration.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Whitespace found at end of line
$parent_entry = new GPNF_Entry( $entry );

Check failure on line 20 in gp-nested-forms/gpnf-set-created-by-property-on-child-entries-after-user-registration.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Tabs must be used to indent lines; spaces are not allowed

Check warning on line 20 in gp-nested-forms/gpnf-set-created-by-property-on-child-entries-after-user-registration.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space
$child_entries = $parent_entry->get_child_entries();

Check failure on line 21 in gp-nested-forms/gpnf-set-created-by-property-on-child-entries-after-user-registration.php

View workflow job for this annotation

GitHub Actions / PHPCS (Files Changed)

Tabs must be used to indent lines; spaces are not allowed

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 23bf3d1

Please sign in to comment.