Last active
January 13, 2021 13:45
-
-
Save Shelob9/cc9abfbb1998d0ac023f974552681d85 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Set a Caldera Forms checkbox field to have mutltiple defaults selected | |
* | |
* Requires: Caldera Forms 1.6 or later | |
* | |
* Important: This only works with checkox fields | |
*/ | |
add_filter( 'caldera_forms_render_get_field', function( $field, $form ){ | |
if( 'fld_9641225' === $field[ 'ID' ] ){ | |
$field[ 'config' ][ 'default' ] = array( | |
'Yes', 'No' | |
); | |
} | |
return $field; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I'm very interested by this solution, but infortunatly I don't manage to make it works.
I've put this code in the functions.php in my child theme + I've changed the 'fld_9641225' by the actual ID of my checkbox file.
Nothing change, I'm afraid I can't find why by my own... Your help would be a lot appreciated ^^
Thks,
Noémie