Created
February 22, 2019 03:45
-
-
Save spivurno/f34460e737d436ce8332e50cb40b8646 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ) { | |
// Update to your value-specific limits. | |
$limits = array( | |
'First Choice' => 1, | |
'Second Choice' => 2, | |
'Third Choice' => 3, | |
); | |
// Get the first and only group. | |
$group =& $groups[0]; | |
$field_id = $group->rulesets[0][0]->get_field(); | |
$value = rgpost( "input_{$field_id}" ); | |
// If no value, don't limit the form. | |
if( ! $value ) { | |
return array(); | |
} | |
$group->limit = rgar( $limits, $value ); | |
return $groups; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment