The gform_disable_form_theme_css Gravity Forms PHP filter allows the default form theme used by forms created with Gravity Forms 2.5 and greater to be disabled.
Usage
To disable the form theme CSS for all forms, use the following code:
add_filter('gform_disable_form_theme_css', 'your_function_name');
Parameters
- $disabled (bool): Whether to disable the theme CSS.
More information
See Gravity Forms Docs: gform_disable_form_theme_css This filter was added in Gravity Forms v2.5.
Examples
Disable the form theme CSS
To disable the form theme CSS for all forms, use the following code:
add_filter('gform_disable_form_theme_css', '__return_true');
Disable the form theme CSS conditionally
To disable the form theme CSS for a specific form only, use the following code:
function disable_theme_css_for_form_1( $disabled ) { if ( 1 == RGFormsModel::get_current_form_id() ) { return true; } return $disabled; } add_filter('gform_disable_form_theme_css', 'disable_theme_css_for_form_1');
Disable the form theme CSS on a specific page
To disable the form theme CSS on a specific page, use the following code:
function disable_theme_css_on_page( $disabled ) { if ( is_page( 'your-page-slug' ) ) { return true; } return $disabled; } add_filter('gform_disable_form_theme_css', 'disable_theme_css_on_page');
Disable the form theme CSS for multiple forms
To disable the form theme CSS for multiple forms, use the following code:
function disable_theme_css_for_multiple_forms( $disabled ) { $form_ids = array( 1, 2, 3 ); if ( in_array( RGFormsModel::get_current_form_id(), $form_ids ) ) { return true; } return $disabled; } add_filter('gform_disable_form_theme_css', 'disable_theme_css_for_multiple_forms');
Disable the form theme CSS when a certain condition is met
To disable the form theme CSS when a certain condition is met, use the following code:
function disable_theme_css_based_on_condition( $disabled ) { if ( your_custom_condition() ) { return true; } return $disabled; } add_filter('gform_disable_form_theme_css', 'disable_theme_css_based_on_condition');
Replace your_custom_condition()
with your custom condition function.