Skip to content

Instantly share code, notes, and snippets.

@matty0501
matty0501 / delete_notification_after_submission.php
Created April 20, 2023 18:20
Delete Gravity Forms Notification Scheduler notifications after submission of a second form
<?php
add_action( 'gform_after_submission_18', function( $entry ){
$first_entry = GFAPI::get_entry( rgar( $entry, 3 ) );
gp_notification_scheduler()->delete_notification_queue( array(), $first_entry );
});
@matty0501
matty0501 / gpcc-copy-label-selectively.js
Last active May 18, 2023 12:06
Selectively apply Gravity Perks Copy Cat "Copy Label (instead of Value)" snippet
/**
* Selectively apply Gravity Perks Copy Cat "Copy Label (instead of Value)" snippet - https://github.com/gravitywiz/snippet-library/blob/master/gp-copy-cat/gpcc-copy-label.js
*/
/**
* Apply snippet to single Copy Cat
*
* In this example, the snippet will apply only in this case:
* - Copying Field ID 3 to Field ID 4
<?php
/**
* Save field in uppercase when form is submitted
*/
add_action( 'gform_pre_submission_123', 'gw_capitalize_submitted_data' ); // Replace 123 with your form ID
function gw_capitalize_submitted_data( $form ) {
$input_key = sprintf( 'input_%s', 1 ); // Replace 1 with your field ID
<?php
/**
* Save multiple fields in different forms as uppercase when form is submitted
*/
add_action( 'gform_pre_submission_123', function ( $form ) { // Change 123 to your first form ID
$fields = array(2,9,12); // Enter your field IDs here, separated by commas. In this case it will apply to fields 2, 9 and 12
<?php
/**
* Prevent Gravity Perks Address Autocomplete scripts from being blocked by SiteGround Optimizer
*/
add_filter( 'sgo_javascript_combine_exclude', 'js_combine_exclude' );
function js_combine_exclude( $exclude_list ) {
$exclude_list[] = 'gp-address-autocomplete';
$exclude_list[] = 'gp-address-autocomplete-google';
<?php
/**
* Modified version of this snippet: https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-capitilize-submitted-data.php
*
* Capitializes all words in Single Line Text, Paragraph Text, Address and Name fields - only when the value is all UPPERCASE or all lowercase
*/
// Update "123" to the ID of the Form
add_action( 'gform_pre_submission_123', 'gw_capitalize_uppercase_lowercase_data' );
function gw_capitalize_uppercase_lowercase_data( $form ) {
<?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' );
<?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.
/**
* 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
/**
* 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' );