Skip to content

Commit eafac98

Browse files
authored
gpdtc-recalc.php: Migrated.
1 parent e21b59b commit eafac98

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

experimental/gpdtc-recalc.php

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,6 @@
11
<?php
22
/**
3-
* Gravity Perks // Date Time Calculator // Recalculate Field Value on View
4-
* https://gravitywiz.com/documentation/gravity-forms-date-time-calculator/
5-
*
6-
* Recalculate a calculated field's value every time it's viewed.
7-
*
8-
* Works great with Date Time Calculator's [:age modifier][1].
9-
*
10-
* [1]: https://gravitywiz.com/documentation/gravity-forms-date-time-calculator/#calculating-age
3+
* We're no longer using the experimental folder for experimental snippets. 🚧
4+
* You can now find the snippet here:
5+
* https://github.com/gravitywiz/snippet-library/blob/master/gp-date-time-calculator/gpdtc-recalc.php
116
*/
12-
add_action( 'wp_loaded', function() {
13-
14-
$form_id = 123; // Change this to the form's ID
15-
$field_id = 4; // Change this to the Calculation field's ID.
16-
17-
$values = array();
18-
19-
add_filter( sprintf( 'gform_get_input_value_%s', $form_id ), function( $value, $entry, $field, $input_id ) use ( $field_id, &$values ) {
20-
if ( $field['id'] !== $field_id ) {
21-
$values[ $field['id'] ] = $value;
22-
return $value;
23-
}
24-
$form = GFAPI::get_form( $entry['form_id'] );
25-
$_entry = $entry + $values;
26-
return GFCommon::calculate( $field, $form, $_entry );
27-
}, 10, 4 );
28-
29-
} );

0 commit comments

Comments
 (0)