Skip to content

Instantly share code, notes, and snippets.

@chrisegg
chrisegg / GravityForms Default Countries
Created June 28, 2022 13:18
List of currently available countries in the Address field country dropdown.
View GravityForms Default Countries
'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' ),
View gf-reset-button.php
<?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.
*
@chrisegg
chrisegg / form-auto-submit.js
Created February 12, 2022 23:58
Allows you to auto-submit a form when the page loads, with a 1/2 second delay. Full tutorial here: https://gravityranger.com/auto-submit-form-page-load/
View form-auto-submit.js
/**
* GravityRanger Auto-Submit Form on Page Load
*
* Allows you to auto-submit a form when the page loads, with a 1/2 second delay.
* https://gravityranger.com/auto-submit-form-page-load/
*
* @instructions:
*
* 1. Change gform_ID# to your forms ID number (line 24)
* 2. Set the amount of time you'd like to delay the script (line 27)
View gr_change_submit_button_text
<?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 / gf-text-redirect-confirmaton.js
Last active December 20, 2021 20:18
Use this code snippet if you'd like to display a text confirmation before redirecting the user to another page/url with Gravity Forms.
View gf-text-redirect-confirmaton.js
/**
* GravityRanger
* https://gravityranger.com/display-text-confirmation-before-redirecting-gravity-forms/
*
* Used to display a text message after a form is submitted, but triggers a redirect 2 seconds after message is displayed.
*
* Instructions: Copy and paste lines 11-17 into a Gravity Forms text confirmaton. Make any necessary changes to the text or number of seconds, i.e 2000 = 2 seconds, (line 16).
*
*/
@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.
View gf-dual-confirmation.php
<?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
*
@chrisegg
chrisegg / login-logout-shortcode.php
Created December 16, 2021 19:51
GravityRanger - Login/Logout Shortcode
View login-logout-shortcode.php
<?php
//copy everything below this line
/**
* GravityRanger Login Logout Shortcode
*
* Creates a login/logout shortcode button
* https://gravityranger.com/login-logout-shortcode-for-gravity-forms-membership-sites/
*
* Used for creating a login/logout shortcode to be used with a WordPress website.
@chrisegg
chrisegg / auto-advance-radio-select-fields.js
Created November 20, 2021 19:20
This snippet will support auto advancing pages in multi-page form for radio button and drop down field types. Full tutorial here: https://gravityranger.com/how-to-build-a-conversational-form-in-gravity-forms
View auto-advance-radio-select-fields.js
<script>
jQuery(document).ready(function($) {
$('input[type=radio], select').on('change', function() {
$(this).closest("form").submit();
});
});
</script>
View gf-product-default-quantity.php
<?php
// Copy everything below this line
add_filter( 'gform_field_value_default_quantity', 'gr_default_qty' );
function gr_default_qty() {
return 0; // change this number to your desired default quantity
}
View gf-inline-button
// @credits https://docs.gravityforms.com/adding-an-inline-submit-button-in-gravity-forms-2-5/
// You will need to replace 123 in gform_submit_button_123 and gform_wrapper_123 with your forms ID number
// Copy everything below this line.
<div>
<button onclick="document.getElementById('gform_submit_button_123').click();" style="height: 2.5rem;padding:0 1rem;font-size:1rem;">
Submit
</button>
</div>