Last active
July 14, 2023 16:47
-
-
Save matty0501/651b15e30f2d9ddfc2f5e41319c7c1b3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 // Ignore the first `n` child entries with `:count` merge tag modifier | |
* https://gravitywiz.com/documentation/gravity-forms-nested-forms | |
* | |
* Also works with `:total` merge tag modifier | |
* | |
* Instructions: | |
* | |
* 1. Install this snippet per https://gravitywiz.com/documentation/how-do-i-install-a-snippet/ | |
* 2. Install accompanying `gpnf-ignore-first-n-entries-in-count.php.js` JavaScript snippet: https://gist.github.com/matty0501/3c9d3d8e99417324bacb78bd7f13bc00 | |
* 3. Customize form ID, field ID(s), and `n` index | |
*/ | |
add_filter( 'gpnf_calc_entries_PARENTFORMID_NESTEDFORMFIELDID', function ( $entries, $match, $nested_form_field, $form, $formula_field ) { | |
// Only change what entries are used for the calculation done in parent field ID 3 | |
if ( rgar( $formula_field, 'id' ) != 3 ) { | |
return $entries; | |
} | |
// Remove the first `n` entries, and return the modified array. Replace 2 with the number of entries you want to remove. | |
$filtered_entries = array_slice( $entries, 2 ); | |
return $filtered_entries; | |
}, 10, 5 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment