Skip to content

Instantly share code, notes, and snippets.

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 Feb 12, 2022
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 Dec 20, 2021
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 May 4, 2022
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 Dec 16, 2021
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 Nov 20, 2021
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>
@chrisegg
chrisegg / gf-limit-payments.php
Last active Sep 6, 2021
Limit Stripe Subscriptions to a Specified Number of Payments
View gf-limit-payments.php
<?php
//Code provided by Gravity Forms here: https://rocketgenius.pxf.io/limit-payments
//Start copying below this line...
add_action( 'gform_post_add_subscription_payment', function ( $entry ) {
gf_stripe()->log_debug( "Running..." );
if ( rgar( $entry, 'payment_status' ) == 'Active' ) {
$feed = gf_stripe()->get_payment_feed( $entry );