The gform_routing_field_types filter in Gravity Forms allows you to modify the field types supported by notification routing.
Usage
To apply the filter to all forms:
add_filter('gform_routing_field_types', 'your_function_name');
Parameters
- $field_types (array): The currently supported field types, generated from GFNotification::$supported_fields.
More information
See Gravity Forms Docs: gform_routing_field_types
Examples
Add a custom field type to supported field types
This code adds a custom field type named ‘my-custom-field-type’ to the supported field types for notification routing.
add_filter('gform_routing_field_types', function($field_types) {
array_push($field_types, 'my-custom-field-type');
return $field_types;
});
Remove a specific field type from supported field types
This code removes the ‘textarea’ field type from the supported field types for notification routing.
add_filter('gform_routing_field_types', function($field_types) {
$key = array_search('textarea', $field_types);
if ($key !== false) {
unset($field_types[$key]);
}
return $field_types;
});
Limit supported field types to specific types
This code limits the supported field types for notification routing to only ‘text’ and ‘number’ field types.
add_filter('gform_routing_field_types', function($field_types) {
return array('text', 'number');
});
Add multiple custom field types to supported field types
This code adds multiple custom field types to the supported field types for notification routing.
add_filter('gform_routing_field_types', function($field_types) {
$custom_field_types = array('custom-type-1', 'custom-type-2', 'custom-type-3');
$field_types = array_merge($field_types, $custom_field_types);
return $field_types;
});
Modify supported field types conditionally based on form ID
This code adds a custom field type named ‘my-custom-field-type’ to the supported field types for notification routing, but only for forms with the ID of 5.
add_filter('gform_routing_field_types', function($field_types, $form_id) {
if ($form_id == 5) {
array_push($field_types, 'my-custom-field-type');
}
return $field_types;
}, 10, 2);