Description
Filter the choice limit for a given choice.
Usage
Apply to all fields on all forms.
add_filter( 'gplc_choice_limit', 'my_custom_function' );
Apply to all fields on a specific form.
add_filter( 'gplc_choice_limit_FORMID', 'my_custom_function' );
Apply to a specific field on a specific form.
add_filter( 'gplc_choice_limit_FORMID_FIELDID', 'my_custom_function' );
Parameters
limit int
The current choice’s limit.
choice array
The current choice array.
form_id int
The current form ID to which the choice belongs.
field_id int
The current field ID to which the choice belongs.
Since
This filter is available since Gravity Forms Limit Choices 1.1.2.
Examples
Filter a specific choice’s limit
Let’s imagine that you have a field (ID: 1) on a form (ID: 123) and you have a default limit of 10 setup for each choice. You want to override a specific choice, identified by its value (e.g. First Choice
) and set its limit to 1
.
add_filter( 'gplc_choice_limit_123_4', function( $limit, $choice ) {
if ( $choice['value'] === 'First Choice' ) {
$limit = 1;
}
return $limit;
}, 10, 2 );