Skip to content

Instantly share code, notes, and snippets.

View claygriffiths's full-sized avatar

Clay Griffiths claygriffiths

View GitHub Profile
<?php
/**
* Gravity Perks // Nested Forms // Force {Parent} Merge Tag Replacement on Submission
* http://gravitywiz.com/documentation/gravity-forms-nested-forms/
*/
add_filter( 'gform_entry_post_save', function ( $entry, $form ) {
$pattern = '/{Parent\:(.+)}/i';
foreach ( $form['fields'] as &$field ) {
if ( $field->get_input_type() == 'form' ) {
@claygriffiths
claygriffiths / gpal-conditional-auto-login.php
Created May 25, 2019 03:11
GP Auto Login: Auto-login based off of field/input having a value or being checked.
<?php
/**
* See https://gravitywiz.com/documentation/how-do-i-install-a-snippet/ for details on how to install snippets like these.
*
* Note: This snippet requires GP Auto Login 1.3.5 or newer.
*
* The following snippet allows you to conditionally auto-login based on whether or not a field has a value
* or is checked.
*
* $form_id should be replaced with the form ID you wish to apply the login to.
@claygriffiths
claygriffiths / gppa-use-choice-value-instead-of-label.php
Created October 2, 2019 01:11
GP Populate Anything: Use Choice Value instead of Label
<?php
/**
* See https://gravitywiz.com/documentation/how-do-i-install-a-snippet/ for details on how to install snippets like these.
*
* The following snippet will set the values in Gravity Forms admin entry view to show the values rather than choices.
**
* $form_id is the form you wish to restrict
*/
add_action('admin_init', function() {
@claygriffiths
claygriffiths / gppa-checkboxes-as-choices.php
Last active December 26, 2019 14:46
GP Populate Anything: Checkboxes from an Entry as Choices
<?php
/**
* See https://gravitywiz.com/documentation/how-do-i-install-a-snippet/ for details on how to install snippets like these.
*
* The following snippet allows you to use a checkbox field as choices.
*
* This will use whatever property is selected in the "Value Template" for the choices.
*
* FORMID is the form that the field with dynamically populated choices is on
* FIELDID is the field ID of the field that you wish to modify the choices for
@claygriffiths
claygriffiths / gppa-populate-choices-with-array.php
Created May 25, 2019 02:15
Populate choices from a property that returns an array.
<?php
/**
* See https://gravitywiz.com/documentation/how-do-i-install-a-snippet/ for details on how to install snippets like these.
*
* The following snippet allows you to use an array to populate the field choices.
*
* This will use whatever property is selected in the "Value Template" for the choices.
*
* FORMID is the form that the field with dynamically populated choices is on
* FIELDID is the field ID of the field that you wish to modify the choices for
@claygriffiths
claygriffiths / gp-copy-cat-copy-label.html
Last active April 22, 2020 05:10 — forked from spivurno/gp-copy-cat-copy-label.html
Gravity Perks // GP Copy Cat // Copy Label (instead of Value)
<!--
Gravity Perks // GP Copy Cat // Copy Label (instead of Value)
http://gravitywiz.com/documentation/gravity-forms-copy-cat/
Instructions:
1. Add an HTML field to your form.
2. Copy and paste the entire contents of this snippet into the "Content" field setting.
-->
<script>
gform.addFilter( 'gppc_copied_value', function( value, $elem, data, sourceValues ) {
@claygriffiths
claygriffiths / gppa-conditionally-disable.html
Created April 23, 2020 03:19
GP Populate Anything: Conditionally Disable Dynamic Population and Live Merge Tags
<!--
Gravity Perks // GP Populate Anything // Conditionally Disable Dynamic Population and Live Merge Tags
https://gravitywiz.com/documentation/gravity-forms-populate-anything/
Instructions:
1. Add an HTML field to your form.
2. Copy and paste the entire contents of this snippet into the "Content" field setting.
3. Change the value of window.disableGPPA to enable/disable dynamic population.
-->
<script>
window.gform.addFilter('gppa_batch_field_html_ajax_data', function(data) {
@claygriffiths
claygriffiths / gw-gravity-forms-calculated-shipping.php
Created April 29, 2020 04:05 — forked from spivurno/gw-gravity-forms-calculated-shipping.php
Gravity Wiz // Gravity Forms // Calculated Shipping
<?php
/**
* Gravity Wiz // Gravity Forms // Calculated Shipping
*
* A simple method for using a calculated product field as a shipping field. This provides the ability to use
* calculations when determining a shipping price.
*
* @version 1.2
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
@claygriffiths
claygriffiths / gw-require-list-columns.php
Created April 30, 2020 03:01 — forked from spivurno/gw-require-list-columns.php
Gravity Wiz // Require All Columns of List Field
<?php
/**
* Require All Columns of List Field
* http://gravitywiz.com/require-all-columns-of-list-field/
*/
class GWRequireListColumns {
private $field_ids;
public static $fields_with_req_cols = array();
@claygriffiths
claygriffiths / gw-gravity-forms-rounding.php
Last active May 5, 2020 03:36 — forked from spivurno/gw-gravity-forms-rounding.php
Gravity Wiz // Gravity Forms // Rounding by Increment
<?php
/**
* Gravity Wiz // Gravity Forms // Rounding by Increment
*
* Provides a variety of rounding functions for Gravity Form Number fields powered by the CSS class setting for each field. Functions include:
*
* + rounding to an increment (i.e. increment of 100 would round 1 to 100, 149 to 100, 150 to 200, etc) | class: 'gw-round-100'
* + rounding up by an increment (i.e. increment of 50 would round 1 to 50, 51 to 100, 149 to 150, etc) | class: 'gw-round-up-50'
* + rounding down by an increment (i.e. increment of 25 would round 1 to 0, 26 to 25, 51 to 50, etc) | class: 'gw-round-down-25'
* + rounding up to a specific minimum (i.e. min of 50 would round 1 to 50, 51 and greater would not be rounded) | class: 'gw-round-min-50'