The gform_shortcode_builder_forms filter allows you to modify the list of available forms displayed in the shortcode builder.
Usage
To use this filter, add the following code snippet:
add_filter('gform_shortcode_builder_forms', 'your_function_name');
Parameters
$forms
(array) – An array of active forms on the site, using the form ID as the key and the form title as the value.
More information
See Gravity Forms Docs: gform_shortcode_builder_forms
Examples
Remove a specific form
This example removes the form with ID 1 from the list of forms that can be embedded using the shortcode builder.
add_filter('gform_shortcode_builder_forms', function($forms) { unset($forms[1]); return $forms; });
Add a custom form
This example adds a custom form with ID 999 and title “Custom Form” to the list of forms that can be embedded using the shortcode builder.
add_filter('gform_shortcode_builder_forms', function($forms) { $forms[999] = "Custom Form"; return $forms; });
Show only forms with specific titles
This example only displays forms with titles containing the word “Event” in the shortcode builder.
add_filter('gform_shortcode_builder_forms', function($forms) { foreach ($forms as $id => $title) { if (strpos($title, 'Event') === false) { unset($forms[$id]); } } return $forms; });
Sort forms by title
This example sorts the list of forms by title in alphabetical order in the shortcode builder.
add_filter('gform_shortcode_builder_forms', function($forms) { asort($forms); return $forms; });
Filter forms by user role
This example only displays forms in the shortcode builder for users with the “editor” role.
add_filter('gform_shortcode_builder_forms', function($forms) { if (current_user_can('editor')) { return $forms; } else { return array(); } });