Last active
December 12, 2017 17:41
-
-
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/
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( '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