Created
December 9, 2019 09:38
Star
You must be signed in to star a gist
Use cf_entry_limiter_entry_limit filter hook for select fields with multiple choices allowed
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 | |
/** | |
* 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