Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Gravity Perks // GF Better User Activation // Set Redirect URL by User Role
* http://gravitywiz.com/documentation/gravity-forms-better-user-activation/
*/
add_filter( 'gpbua_activation_redirect_url', function( $url, $activation ) {
// Enter the roles and redirect URLs
$redirects = array(
'subscriber' => 'https://google.com',
<?php
/**
* Gravity Perks // Populate Anything // Range Modifier for Live Merge Tags
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
*
* Use the :range modifier with checkbox merge tags to get the range of checked options
* Works well with the :value modifier
*
* Will return `x - y` where the min and max are different, or `x` if they are the same
<?php
/**
* Gravity Perks // GP Google Sheets // Admin Columns Pro Inline Edit Compatability
*
* Allow the Google Sheet to be updated after the entry is edited by Admin Columns Pro Inline Edit
*
* Installation:
* 1. Install per https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
*/
add_action( 'acp/editing/saved', function ( AC\Column $column, $id ) {
/**
* Gravity Perks // GP Nested Forms // Ignore the first `n` child entries with `:count` merge tag modifier
* https://gravitywiz.com/documentation/gravity-forms-nested-forms
*
* Also works with `:total` merge tag modifier
*
* Instructions:
*
* 1. Install this snippet with our free Custom JavaScript plugin.
* https://gravitywiz.com/gravity-forms-custom-javascript/
<?php
/**
* Gravity Perks // GP Nested Forms // Ignore the first `n` child entries with `:count` merge tag modifier
* https://gravitywiz.com/documentation/gravity-forms-nested-forms
*
* Also works with `:total` merge tag modifier
*
* Instructions:
*
* 1. Install this snippet per https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
<?php
/**
* Gravity Perks // Populate Anything // Populate Pipe Video URL
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
*
* By default, when populating a Pipe field's value, the Pipe add-on returns an array which includes the video URL and a thumbnail.
* This snippet allows you to just populate the video URL.
* Just add the "gppa-pipe-video" CSS class to the populated field's CSS Class Name setting.
*/
add_filter( 'gppa_process_template_value', function( $template_value, $field ) {
<?php
/**
* Gravity Wiz // Nested Forms // Populate Parent Entry ID in Child Entry
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
*
* Populate the parent entry ID into a field in the child entry upon submission of the parent form.
*/
add_action( 'gform_after_submission_123', function( $entry, $form ) { // Replace 123 with your parent form ID
$parent_entry = new GPNF_Entry( $entry );
$parent_id = rgar( $entry, 'id' );
/**
* Selectively apply Gravity Perks Copy Cat "Copy Label for List Field Drop Downs" snippet - https://github.com/gravitywiz/snippet-library/blob/master/gp-copy-cat/gpcc-copy-label-list-field-drop-downs.js
*/
/**
* Apply snippet to single Copy Cat
*
* In this example, the snippet will apply only in this case:
* - Copying Field ID 1 to Field ID 2
<?php
/**
* This is a modified version of this snippet: https://github.com/gravitywiz/snippet-library/blob/master/gp-address-autocomplete/gpaa-show-place-name.php
*
* Find addresses by their name and prepend place name to address line 1.
* Also allows searching by UK post codes and does not populate place name if this is equal to post code.
*
* Developer's Note: The JS in this snippet cannot be included via the Custom Javascript plugin due
* to an order-of-events issue with GPAA calling the options filter before the Custom Javascript plugin
* has initialized.
<?php
/**
* Use this snippet to populate a Gravity Forms dropdown with years as choices, starting with the current year
* By default, the snippet will return four years, including the current year
* For example, the current year is 2023, so the dropdown choices would be 2023, 2024, 2025, 2026
* You will need to add the css class "populate-years" to the dropdown
*/
// Change 123 to your form ID
add_filter( 'gform_pre_render_123', 'populate_posts' );