Skip to content

Instantly share code, notes, and snippets.

@scyt
scyt / gppa-prepend-lmt-with-dash.php
Created December 9, 2022 20:25
Prepend Live Merge Tags with Dash Character
<?php
// Update "123" with your form ID and "4" with your source field ID.
add_filter( 'gppa_live_merge_tag_value_123_4', function( $value, $merge_tag, $form, $field_id, $entry_values ) {
if ( !$value ) {
return $value;
}
return "-" . $value;
}, 10, 5 );
<?php
/**
* Gravity Perks // GP Nested Forms // Reorder Nested Form Field Columns
*
* Reorder the columns in the Nested Form Field summary table.
*
* @version 0.1
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
* @link http://gravitywiz.com/documentation/gravity-forms-nested-forms/
/**
* Gravity Perks // Pay Per Word // Surprise, Pay Per Line!
* https://gravitywiz.com/documentation/gravity-forms-pay-per-word/
*/
gform.addFilter( 'gpppw_word_count', function( wordCount, text, gwppw, ppwField, formId ) {
// Pay per character instead of words.
var words = text.split( '\n' );
return words == null ? 0 : words.length;
} );
@scyt
scyt / gp-limit-dates-populate-and-show-minimum-linked-date.js
Last active May 19, 2020 17:34
GP Limit Dates // Gravity Perks // Populate and Show Minimum Linked Date
<script>
if( window.gform ) {
gform.addAction( 'gpld_after_set_min_date', function( $input, date ) {
$input.datepicker( 'show' );
$input.datepicker( 'setDate', date );
} );
}
</script>
/**
* Gravity Perks // Pay Per Word // Ignore Words Between Parentheses (JS)
* https://gravitywiz.com/documentation/gravity-forms-pay-per-word/
*/
gform.addFilter( 'gpppw_word_count', function( wordCount, text, gwppw, ppwField, formId ) {
// Removes words between parentheses.
var words = text.replace( /\(([^)]+)\)/g, '' ).match( /\S+/g );
return words == null ? 0 : words.length;
} );
@scyt
scyt / gw-time-merge-tags.php
Created May 5, 2020 14:10
Gravity Wiz // Gravity Forms // Time Merge Tags
<?php
/**
* Gravity Wiz // Gravity Forms // Time Merge Tags
*
* Adds {time_hh}, {time_hh:12}, {time_hh:24}, {time_mm}, and {time_am_pm} merge tags.
*
* @version 1.0
* @author Ryan Donovan <ryan@gravitywiz.com>
* @license GPL-2.0+
* @link http://gravitywiz.com/...
@scyt
scyt / gp-nested-forms-preview-files.php
Last active January 12, 2022 19:01
Gravity Perks // Nested Forms // Preview Files Uploaded With GP Media Library
<?php
/**
* WARNING! THIS SNIPPET MAY BE OUTDATED.
* The latest version of this snippet can be found in the Gravity Wiz Snippet Library:
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-current-time-merge-tags.php
*/
/**
* Gravity Perks // Nested Forms // Preview Files Uploaded With GP Media Library
*
* @version 1.0
@scyt
scyt / gw-image-preview.html
Last active February 27, 2020 20:27
Gravity Wiz // Gravity Forms // Preview Image of File Upload
<div id="preview" style="display:none;">
<img src="" style="width:150px;">
</div>
@scyt
scyt / gp-copy-cat-gppc_last_list_item.js
Last active February 4, 2020 22:22
Gravity Perks // GP Copy Cat // Last Item In List
<script type="text/javascript">
/**
* Gravity Perks // GP Copy Cat // Last Item In List
*
* Only copy the last item in a list field to the target field
*
* @version 1.0
* @author Scott Buchmann <scott@gravitywiz.com>
* @license GPL-2.0+
* @link http://gravitywiz.com/...
<?php
/**
* Gravity Wiz // Gravity Forms // Edit Entry
*
* Edit entry ID specified in field with current form submission.
*
* @version 1.0
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
* @link http://gravitywiz.com/...