Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spivurno/f34460e737d436ce8332e50cb40b8646 to your computer and use it in GitHub Desktop.
Save spivurno/f34460e737d436ce8332e50cb40b8646 to your computer and use it in GitHub Desktop.
<?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