Create a gist now

Instantly share code, notes, and snippets.

Gravity Forms - Add new predefined bulk choices (including specifying label and value)
add_filter('gform_predefined_choices', 'lunarwp\add_predefined_choice');
* Add custom Bulk Predefined Choices to Gravity Forms for Regions
* @since 1.0.0
* @param array $choices Predefined choices array
* @return array Amended array with our new choices added
function add_predefined_choice($choices)
//* (optional) Fetch the colors from somewhere in the database to avoid hard-coding
//* Or just manually build it here
$colors['Custom Colors'] = array(
'Black | 000',
'White | fff',
'Gray | 555',
'Blue | 049cdb',
//* To avoid scrolling down the list when you open up the Bulk Choices,
//* let's add it to the top of the $choices array.
$choices = $colors + $choices;
return $choices;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment