Skip to content

Instantly share code, notes, and snippets.

@spivurno
spivurno / gp-limit-submissions-dynamically-set-limit.php
Created September 26, 2018 11:24
Gravity Perks // GP Limit Submissions // Dynamically Set Limit
<?php
/**
* Gravity Perks // GP Limit Submissions // Dynamically Set Limit
* http://gravitywiz.com/gravity-forms-limit-submissions/
*/
add_filter( 'gpls_rule_groups', function( $rule_groups ) {
foreach( $rule_groups as &$rule_group ) {
if( $rule_group->name == 'Your Feed Name' ) {
$rule_group->limit = 100;
@spivurno
spivurno / gp-limit-submissions-poll-results.php
Last active November 26, 2020 19:58
Gravity Perks // GP Limit Submissions // Display Poll Results When Limit Is Reached
<?php
/**
* Gravity Perks // GP Limit Submissions // Display Poll Results When Limit Is Reached
* http://gravitywiz.com/documentaiton/gravity-forms-limit-submissions/
*/
add_action( 'gform_get_form_filter', function( $markup, $form ) {
if( ! is_callable( 'gf_polls' ) || ! gf_polls()->get_form_setting( $form, 'displayResults' ) ) {
return $markup;
}
@spivurno
spivurno / gw-styles-pro-force-validation-message.php
Created July 20, 2018 02:43
Gravity Wiz // Gravity Forms Styles Pro // Force Validation Message
<?php
/**
* Gravity Wiz // Gravity Forms Styles Pro // Force Validation Message
* http://gravitywiz.com
*/
if( class_exists( 'StylesPro' ) ) {
add_filter( 'gform_validation_message', function( $message, $form ) {
add_filter( "gform_validation_message_{$form['id']}", array( StylesPro::get_instance(), 'gf_stylespro_validation'), 11, 2 );
}, 10, 2 );
}
@spivurno
spivurno / gp-nested-forms-require-unique-values.php
Last active December 3, 2021 14:57
Gravity Perks // GP Nested Forms // Require Unique Value Between Parent & Child
<?php
/**
* WARNING! THIS SNIPPET MAY BE OUTDATED.
* The latest version of this snippet can be found in the Gravity Wiz Snippet Library:
* https://github.com/gravitywiz/snippet-library/blob/master/gp-nested-forms/gpnf-require-unique-values.php
*/
/**
* Gravity Perks // GP Nested Forms // Require Unique Value Between Parent & Child
*
* Throw a validation error if a value is present a child entry that has been entered on the parent form.
@spivurno
spivurno / gw-gravity-forms-page-navigation-step-n-of-x.php
Last active April 23, 2018 16:46
Gravity Wiz // Gravity Forms // Display Navigation as "Step {currentPage} of {totalPages}"
<?php
/**
* Gravity Wiz // Gravity Forms // Display Navigation as "Step {currentPage} of {totalPages}"
* http://gravitywiz.com/
*/
add_filter( 'gform_progress_steps', function( $progress_steps, $form, $page ) {
$page = GFFormDisplay::get_current_page( $form['id'] );
$progress_steps = sprintf( 'Step %d of %d', $page, GFFormDisplay::get_max_page_number( $form ) );
@spivurno
spivurno / gp-limit-dates-block-date-range.php
Created April 12, 2018 12:40
Gravity Perks // GP Limit Dates // Block Date Range via Exceptions
<?php
/**
* Gravity Perks // GP Limit Dates // Block Date Range via Exceptions
*/
add_filter( 'gpld_limit_dates_options_1364_1', 'gpld_except_date_range', 10, 3 );
function gpld_except_date_range( $options, $form, $field ) {
$start_date = '2016-07-15';
$end_date = '2017-01-01';
@spivurno
spivurno / gp-nested-forms-user-registration-map-full-child-entry-data.php
Last active January 25, 2022 21:17
Gravity Perks // GP Nested Forms // Map Full Child Entry Data via User Registration Add-on
<?php
/**
* Gravity Perks // GP Nested Forms // Map Full Child Entry Data via User Registration Add-on
* http://gravitywiz.com/documentation/gravity-forms-nested-forms/
*/
add_action( 'gform_user_registration_meta_value', function( $value, $meta_key, $meta, $form, $entry, $is_username ) {
if( ! is_callable( 'gp_nested_forms' ) || ! gp_nested_forms()->has_nested_form_field( $form ) ) {
return $value;
}
@spivurno
spivurno / gp-post-content-merge-tags-support-plus-signs.php
Created March 28, 2018 16:14
Gravity Perks // GP Post Content Merge Tags // Support Plus Signs when Populating a Form
<?php
/**
* Gravity Perks // GP Post Content Merge Tags // Support Plus Signs when Populating a Form
* https://gravitywiz.com/documentation/gravity-forms-post-content-merge-tags/
*/
add_filter( 'shortcode_atts_gravityforms', function( $out, $pairs, $atts, $shortcode ) {
if( isset( $out['field_values'] ) ) {
$out['field_values'] = str_replace( '+', '%2B', $out['field_values'] );
}
@spivurno
spivurno / gw-gravity-forms-save-and-continue-auto-load.php
Last active August 19, 2021 19:36
Gravity Wiz // Gravity Forms // Automatic Save & Continue
<?php
/**
* Gravity Wiz // Gravity Forms // Automatic Save & Continue
*
* Automatically save
* load previously saved data (via Gravity Forms' Save & Continue functionality) when a logged-in user views a form.
*
* @version 0.4
* @author David Smith <[email protected]>
* @license GPL-2.0+
@spivurno
spivurno / gp-copy-cat-copy-other-radio-button.html
Created January 26, 2018 14:44
Gravity Perks // GP Copy Cat // Copy Other Radio Button
<script>
/**
* Gravity Perks // GP Copy Cat // Copy Other Radio Button
* http://gravitywiz.com/documentation/gravity-forms-copy-cat/
*/
gform.addFilter( 'gppc_copied_value', function( value, $targetElem, field ) {
if( $targetElem.attr( 'id' ).split( '_' ).pop() == 'other' ) {
value = jQuery( '#input_' + field.sourceFormId + '_' + field.source + '_other' ).val();
}
return value;