Skip to content

Instantly share code, notes, and snippets.

@spivurno
Last active September 3, 2020 20:04
Show Gist options
  • Save spivurno/9fe7f690d716c30913f2f37d3a608c51 to your computer and use it in GitHub Desktop.
Save spivurno/9fe7f690d716c30913f2f37d3a608c51 to your computer and use it in GitHub Desktop.
<?php
/**
* Gravity Perks // GP Limit Submissions // Apply Limit Collectively to Group of Forms
* http://gravitywiz.com/documentation/gravity-forms-limit-submissions/
*/
add_filter( 'gpls_rule_groups', function( $rule_groups, $form_id ) {
// Update "123" to the ID of the form that will share its feeds with the other forms.
$primary_form_id = 123;
// Update the following to the form IDs of each form that should share the limits of the primary form.
$group_form_ids = array( 124, 125, 126 );
// STOP! No need to edit below this line.
$applicable_forms = array_merge( array( $primary_form_id ), $group_form_ids );
if( ! in_array( $form_id, $applicable_forms ) ) {
return $rule_groups;
}
$rule_groups = array_merge( $rule_groups, GPLS_RuleGroup::load_by_form( $primary_form_id ) );
foreach( $rule_groups as $rule_group ) {
$rule_group->applicable_forms = $applicable_forms;
}
return $rule_groups;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment