Skip to content

Instantly share code, notes, and snippets.

@chrisegg
chrisegg / gforms-multi-date-picker.php
Created November 5, 2024 22:56
Gravity Forms: Adds the calendar picker to a single line text field and supports selecting multiple dates in the text field.
<?php
/**
* Gravity Forms // Multi-Date Picker Field
* https://gravityranger.com/gravity-forms-multi-date-picker/
*
* Allows selection of multiple dates in a single Gravity Forms text field.
*
* Step-by-Step Tutorial: https://gravityranger.com/gravity-forms-multi-date-picker/
*
* Instructions:
@chrisegg
chrisegg / gforms-limit-coupon-per-customer.php
Created November 5, 2024 22:54
Snippet will compare the email address to the coupon entered if the email has already been used validation fails, and a custom validation message is shown.
<?php
/**
* Gravity Forms // Limit Coupine Usage Per Customer Based on Email Address
* https://gravityranger.com/gravity-forms-limit-coupon-per-customer/
*
* Snippet will compare the email address to the coupon entered if the email has already
* been used validation fails, and a custom validation message is shown.
*
* Step-by-Step Tutorial: https://gravityranger.com/gravity-forms-limit-coupon-per-customer/
*
@chrisegg
chrisegg / gforms-hide-from-entries.php
Created November 5, 2024 22:51
Using a CSS class 'hide-from-entries' you can prevent fields from showing in the entry details page. Add the class to the fields Custom CSS Class area.
<?php
/**
* Gravity Forms // Remove fields from entry details page
* https://gravityranger.com/
*
* Using a CSS class 'hide-from-entries' you can prevent fields from showing in the entry
* details page. Add the class to the fields Custom CSS Class area.
*
* Step-by-Step Tutorial: https://gravityranger.com/gravity-forms-hide-from-entries/
@chrisegg
chrisegg / change-radio-choice-selection.js
Created October 17, 2024 23:38
This snippet will change a selection in a radio button field when entering a value to another field.
/**
* Gravity Ranger // Gravity Forms // Change radio button choice when adding value to another field
* https://gravityranger.com/gravity-forms-fancy-donation-form
*
* This snippet will change a selection in a radio button field when entering a value to another field.
* Intended for a donation form with a price select field and and a user defined price field.
*
*/
<script type="text/javascript">
@chrisegg
chrisegg / select-field-choice-button-click.js
Created August 23, 2024 16:15
this snippet will allow you to add a button to your page with a specific CSS class that, when clicked, will make a selection in a radio button field choice. You must map the field choices in this code using the choice values.
/**
* GravityRanger // Gravity Forms // Select Field Choice with Button Click
* https://gravityranger.com/linking-button-to-gravity-forms-radio-button-choice/
*
* By default, this snippet will allow you to add a button to your page with a specific CSS class that, when clicked,
* will make a selection in a radio button field choice. You must map the field choices in this code using the choice values.
*/
// You will need to modify the code replacing basic, pro, and elite with your CSS classes and choice values
@chrisegg
chrisegg / check-all-mark-as-spam.php
Created April 12, 2024 03:56
This snippet with check a specific checkbox field in a specific form to see if all choices have been selected, if it they are the entry will be marked as spam.
<?php
//Copy everything below this line
/**
*
* Mark entry as spam if all checkbox choices are selected
*
* This is a unique use case, but if you have a checkbox that selecting all choices is unlikely you can use this as a spam prevention method.
*
*
//Copy everything below this line
/**
*
* Conditionally Disable Radio Button Field
*
* This snippet disables a radio button field when a specific choice is selected in another radio button field.
* It will even clear the choice selection of the disabled field.
* See the link below for instructions.
*
@chrisegg
chrisegg / gr-limit-checkbox-selection.js
Created October 17, 2023 01:04
This snippet allows you to limit the number of checkboxes that can be checked, and grays out and disables all other choices when that number is reached.
/**
* GravityRanger Limit Checkboxes
*
* This snippet allows you to limit the number of checkboxes that can be checked, and grays out and disables all other choices when that number is reached.
*
*
* @instructions:
*
* 1. Change 2 on line 24 to the number of checkbox choices you want the user to be able to select.
* 2. Change the 1_5 on line 27 to the formID_fieldID of your checkbox field.
@chrisegg
chrisegg / entry-details-view-log-button-metabox.php
Created October 16, 2023 23:38
This snippet adds a button to the entry details page that allows you to easily view the Gravity Forms core log file when enabled.
<?php
//Copy everything below this line
/**
*
* Entry Details Log Button
*
* This snippet adds a button to the entry details page that allows you to easily view the Gravity Forms core log file when enabled.
*
* @Version: 1.0
@chrisegg
chrisegg / change-admin-email.php
Created August 19, 2023 21:46
Use this to change the {admin_email} for all Gravity Forms Admin Notifications
<?php
//copy everything below this line
add_filter( 'gform_notification', 'change_notification_email', 10, 3 );
function change_notification_email( $notification, $form, $entry ) {
if ( $notification['name'] == 'Admin Notification' ) {
// toType can be routing or email