Skip to content

Instantly share code, notes, and snippets.

<script type="text/javascript">
gform.addFilter( 'gppc_copied_value', function( value, $elem, data ) {
// Update "1" to the ID of the field being copied to.
if( data.target == 1 && value ) {
value = value.split( '|' )[0];
}
return value;
} );
<?php
/**
* Gravity Perks // Nested Forms // Delay Child Notifications for Parent Payment
* http://gravitywiz.com/documentation/gravity-forms-nested-forms/
*/
add_filter( 'gpnf_should_send_notification', function( $should_send_notification, $notification, $context, $parent_form, $nested_form_field, $entry, $child_form ) {
if( $context == 'parent' ) {
$parent_entry = GFAPI::get_entry( rgar( $entry, 'gpnf_entry_parent' ) );
$should_send_notification = in_array( rgar( $parent_entry, 'payment_status' ), array( 'Paid', 'Active' ) );
<?php
/**
* Gravity Perks // Populate Anything // Populate Post Meta as Choices
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
*/
// Update "123" with your form ID; Update "4" with your field ID.
add_filter( 'gppa_input_choices_123_4', function( $choices, $field, $objects ) {
$custom_field = str_replace( 'meta_', '', $field['gppa-choices-templates']['label'] );
$meta = get_post_meta( $objects[0]->ID, $custom_field );
<?php
/**
* Gravity Perks // Multi-page Navigation // Bypass Validation on Next
* https://gravitywiz.com/documentation/gravity-forms-multi-page-navigation/
*
* Bypass validation when clicking the next button. Navigation Activation Type must be set to "from the start".
*/
add_filter( 'gform_form_tag', function( $tag ) {
$tag .= '<input type="hidden" name="gw_bypass_validation" value="1">';
return $tag;
<?php
/**
* GP Unique ID // Gravity Perks // Date-specific Sequences
* http://gravitywiz.com/
*
* Requirements:
* - Your form ID cannot be more than 3 digits.
* - Your field ID cannot be more than 2 digits.
*/
// Update "123" to your form ID. Update "4" to your Unique ID field ID.
<?php
/**
* Gravity Perks // Nested Forms // Hourly Cron & Orphaned Entry Expiration
* http://gravitywiz.com/documentation/gravity-forms-nested-forms/
*/
function gpnf_custom_hourly_cron() {
if( ! is_callable( 'gp_nested_forms' ) ) {
return;
}
<?php
/**
* Gravity Perks // Conditional Pricing + GravityView // Fix Page Number Validation Conflict
* http://gravitywiz.com/documentation/gravity-forms-conditional-pricing/
*/
add_filter( 'gform_pre_validation', function( $form ) {
if( is_callable( 'gravityview' ) && gravityview()->request->is_edit_entry() !== false ) {
foreach( $form['fields'] as &$field ) {
$field->pageNumber = 1;
}
<?php
/**
* Gravity Perks // Limit Submissions // Value-specific Limits by Field
* http://gravitywiz.com/documentation/gravity-forms-limit-submissions/
*
* Form Export: https://gwiz.io/2Nm2JC2
* Feed Config: https://gwiz.io/2GJ2mRV
*/
// Update "123" to your form ID.
add_filter( 'gpls_rule_groups_123', function( $groups ) {
<?php
/**
* Gravity Perks // eCommerce Fields // Consolidate Separate Discount Line Items into a Single Discounts Line Item
* http://gravitywiz.com/documentation/gravity-forms-ecommerce-fields/
*
* Default: https://gwiz.io/2IiPALf
* w/ Snippet: https://gwiz.io/2Itfyfo
*/
// Update "123" to your form ID - or - remove "_123" to apply to all forms.
add_filter( 'gpecf_order_summary_123', function( $summary ) {
<?php
/**
* Gravity Perks // Limit Dates // Disable All Dates & Set Enabled Dates via Exceptions
* http://gravitywiz.com/documentation/gravity-forms-limit-dates/
*/
add_filter( 'gpld_limit_dates_options_123_1', function( $options, $form, $field ) {
$options['exceptionMode'] = 'enable';
$options['disableAll'] = true;