Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Last active December 12, 2017 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shelob9/670848bb8fe73769a152857efe2c1263 to your computer and use it in GitHub Desktop.
Save Shelob9/670848bb8fe73769a152857efe2c1263 to your computer and use it in GitHub Desktop.
Example code for cf_entry_limiter_entry_limit filter. See: https://calderaforms.com/doc/cf_entry_limiter_entry_limit/
<?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( 'frisbee' === $entry ){
$limit = 10;
}elseif ( '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