Skip to content

Commit d6e5edf

Browse files
authored
gpppw-capture-count-as-field-value.js: Fixed an issue with snippet not working with Conditional Logic in play.
1 parent 7808a1c commit d6e5edf

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

gp-pay-per-word/gpppw-capture-count-as-field-value.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
* [1]: https://gravitywiz.com/gravity-forms-code-chest/
1010
*/
1111
gform.addFilter( 'gpppw_word_count', function( wordCount ) {
12-
// Update "4" to the ID of the field which should be populated with the word count.
13-
$( '#input_GFFORMID_4' ).val( wordCount ).change();
12+
// Update "2" to the ID of the field which should be populated with the word count.
13+
var $field = $( '#input_GFFORMID_2' );
14+
15+
// Only update if value is actually different
16+
if ( $field.val() != wordCount ) {
17+
$field.val( wordCount ).change();
18+
}
19+
20+
return wordCount;
1421
}, 11 );

0 commit comments

Comments
 (0)