Skip to content

Instantly share code, notes, and snippets.

@New0
Created December 9, 2019 09:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save New0/f4136fe888df79714083b7637bbbcf90 to your computer and use it in GitHub Desktop.
Use cf_entry_limiter_entry_limit filter hook for select fields with multiple choices allowed
<?php
/**
* Allow different field values of same field to have different limits when using Caldera Forms Entry Limitter
*
* Requires version 1.2.0 or later
*/
add_filter( 'cf_entry_limiter_entry_limit', function( $limit, $entry, $field, $form ){
//IMPORTANT: Change fld_9970286 to your field's ID
if( 'fld_9970286' === $field[ 'ID' ] ){
//IMPORTANT: Use the field values (not labels) in these conditionals
//change max entries for frisbee to 10
if( in_array( 'frisbee', $entry ) ){
$limit = 10;
}elseif ( in_array( 'video-games', $entry ) ){
$limit = 10;
}else{
$limit = 12;
}
}
return $limit;
}, 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment