Skip to content

Instantly share code, notes, and snippets.

@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
@chrisegg
chrisegg / gf-dual-confirmation.php
Last active March 26, 2023 20:37
Uses the gform_confirmation hook to display a text confirmation message before triggering the redirect confirmation.
<?php
// Copy everything below this line
/**
* GravityRanger Dual Confirmation (text + redirect)
* https://gravityranger.com/display-text-confirmation-before-redirecting-gravity-forms
*
* Uses the gform_confirmation hook to display a text confirmation message before triggering the redirect confirmation.
* This code is a modified version of the snippet provided on docs.gravityfroms.com
*
<?php
//Copy everything below this line
/**
* GravityRanger Change Submit Button Text
*
* Allows you to change the submit button text after the button is clicked.
* https://gravityranger.com/change-gravity-forms-submit-button-text-after-submission/
*
* @instructions:
@chrisegg
chrisegg / GravityForms Default Countries
Created June 28, 2022 13:18
List of currently available countries in the Address field country dropdown.
'AF' => __( 'Afghanistan', 'gravityforms' ),
'AX' => __( 'Åland Islands', 'gravityforms' ),
'AL' => __( 'Albania', 'gravityforms' ),
'DZ' => __( 'Algeria', 'gravityforms' ),
'AS' => __( 'American Samoa', 'gravityforms' ),
'AD' => __( 'Andorra', 'gravityforms' ),
'AO' => __( 'Angola', 'gravityforms' ),
'AI' => __( 'Anguilla', 'gravityforms' ),
'AQ' => __( 'Antarctica', 'gravityforms' ),
'AG' => __( 'Antigua and Barbuda', 'gravityforms' ),
<?php
/**
*
* GravityRanger // Gravity Forms Reset Button
* https://gravityranger.com/gravity-forms-reset-button/
*
* Use this code snippet to add a reset button to your forms.
* Code snippet will add the button to all forms by default.
*