Skip to content

Instantly share code, notes, and snippets.

@scyt
scyt / gw-gravity-forms-product-count.php
Last active August 7, 2019 20:43 — forked from spivurno/gw-gravity-forms-product-count.php
Gravity Wiz // Gravity Forms // Product Count
<?php
/**
* Gravity Wiz // Gravity Forms // Product Count
*
* Get the total number of products selected. Particularly useful in combination with the GP Conditional Pricing
* perk to create pricing rules based on product count.
*
* @version 1.0
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
@scyt
scyt / gw-gravity-forms-rename-uploaded-files-usage.php
Last active September 3, 2019 14:42 — forked from spivurno/gw-gravity-forms-rename-uploaded-files-usage.php
Gravity Wiz // Gravity Forms // Rename Uploaded Files
<?php
# First and Last Name
new GW_Rename_Uploaded_Files( array(
'form_id' => 628,
'field_id' => 3,
'template' => '{Name (First):1.3}-{Name (Last):1.6}-{filename}' // most merge tags are supported, original file extension is preserved
) );
# Form Title Merge Tag
<?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/...
@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/...
@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-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-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/...
/**
* 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 / 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 // 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;
} );