Skip to content

Instantly share code, notes, and snippets.

@spivurno
spivurno / gw-modified-subtotals.php
Created May 2, 2014 21:39
Gravity Wiz // Gravity Forms // Subtotal Merge Tag // Support Modified Subtotals
<?php
/**
* On the front-end, GF Calculations will include other calculation fields in the calculation formula, even if that
* calculation field comes after the field being currently calculated. On the back-end, calculation fields in formulas
* for other calculation fields that preceed them, are not contributed towards that calculated total.
*
* This means if you are using the {subtotal} merge tag (http://gravitywiz.com/subtotal-merge-tag-for-calculations/) to
* show the Subtotal and then using the {subtotal} merge tag in a field after that subtotal field to add tax, you would
* need to modify the Subtotal field to subtract the tax field amount.
*
@spivurno
spivurno / gw-surve-get-selected-choice.php
Created June 30, 2014 18:25
Get the selected survey choice based on entry value.
/**
* Get the selected survey choice based on entry value.
*/
function gw_survey_get_selected_choice( $entry, $field_id ) {
$form = GFAPI::get_form( $entry['form_id'] );
$key = rgar( $entry, $field_id );
foreach( $form['fields'] as $field ) {
@spivurno
spivurno / gw-add-spaces-for-multi-select-merge-tag.php
Created August 19, 2014 00:10
Gravity Wiz // Gravity Forms // Add Spaces for Multi Select Merge Tag
<?php
add_filter( 'gform_merge_tag_filter', 'gw_add_spaces_for_multi_select_merge_tag', 10, 5 );
function gw_add_spaces_for_multi_select_merge_tag( $value, $merge_tag, $options, $field, $raw_value ) {
if( GFFormsModel::get_input_type( $field ) == 'multiselect' && $merge_tag == $field['id'] ) {
$value = implode( ', ', explode( ',', $value ) );
}
return $value;
@spivurno
spivurno / gp-limit-choices-gwlc_approved_payments_only.php
Created September 3, 2014 02:47
Gravity Wiz // Gravity Perks // GP Limit Choices // Only count approved payments towards limit
<?php
# Apply to all forms
add_filter( 'gwlc_approved_payments_only', '__return_true' );
# Apply to specific form (i.e. form ID #1)
add_filter( 'gwlc_approved_payments_only_1', '__return_true' );
@spivurno
spivurno / gp-limit-choices-hide-form-if-choices-exhausted.php
Created September 16, 2014 04:29
Gravity Perks // GP Limit Choices // Hide Form if Choices Exhausted
/**
* Gravity Perks // GP Limit Choices // Hide Form if Choices Exhausted
* http://gravitywiz.com/documentation/gp-limit-choices/
*
* Hide the form and display a message when the limit has been reached for a Limit-enabled field. This example will hide the form
* if *any* choice is exhausted so it is best used if there is only one field with limits enabled.
*/
add_filter( 'gform_pre_render', 'gw_disable_form_if_choices_exhausted', 12 );
function gw_disable_form_if_choices_exhausted( $form ) {

Keybase proof

I hereby claim:

  • I am spivurno on github.
  • I am spivurno (https://keybase.io/spivurno) on keybase.
  • I have a public key whose fingerprint is 8079 11CF 8F94 E737 36C9 BA47 1D52 E881 0BCF 5400

To claim this, I am signing this object:

@spivurno
spivurno / gp-terms-of-service-shortcode-support.php
Last active August 29, 2015 14:08
Gravity Perks // GP Terms of Service Field // Add Support for Using Shortcodes in Terms Field
/**
* Gravity Perks // GP Terms of Service Field // Add Support for Using Shortcodes in Terms Field
* http://gravitywiz.com/documentation/gp-terms-of-service/
*
* This plug-in-play snippet adds support for shortcodes in terms. It will automatically convert the ToS fields for the given
* form into the HTML-enabled version (default uses <textarea> which does not support HTML).
*
* One way this snippet can be used is in conjuction with the [Post Content Shortcodes](https://wordpress.org/plugins/post-content-shortcodes/)
* which provides a shortcode to retrive the content of a post. You can keep your terms in a single post and then use a
* shortcode (i.e. [post-content id="12"])to display those terms in all of your ToS fields.
@spivurno
spivurno / gw-gravity-forms-input-id-changes.html
Last active August 29, 2015 14:14
Gravity Wiz // Gravity Forms // GF 1.8.21 Radio Button & Checkbox Input Id Change
<!-- New Id -->
<input name="input_2.1" type="checkbox" value="First Choice" id="choice_294_2_1" tabindex="4">
<!-- Old Id -->
<input name="input_2.1" type="checkbox" value="First Choice" id="choice_2_1" tabindex="4">
@spivurno
spivurno / tt-gf-quantity-bump.php
Last active August 29, 2015 14:15
Ounce of Talent // Gravity Forms // Bump Quantity Up Depending on Whether a Field is Checked
<?php
/**
* Ounce of Talent // Gravity Forms // Bump Quantity Up Depending on Whether a Field is Checked
*
* A brief description about this snippet and the functionality it provides. Might also include basic usage instructions if applicable.
*
* @version 1.0
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
* @link http://gravitywiz.com/...
@spivurno
spivurno / gp-price-range-modify-validation-messages.php
Created April 22, 2015 01:53
Gravity Perks // GP Price Range // Modify Validation Messages
<?php
/**
* Gravity Perks // GP Price Range // Modify Validation Messages
*/
add_filter( 'gform_validation', function( $result ) {
foreach( $result['form']['fields'] as &$field ) {
if( ! $field['failed_validation'] ) {
continue;