Using Gravity Forms ‘gform_print_styles’ PHP action

The gform_print_styles filter allows you to add custom stylesheets to the print entry screen in Gravity Forms.

Usage

add_filter('gform_print_styles', 'your_function_name', 10, 2);

Parameters

  • $value (boolean) – Defaults to false.
  • $form (Form Object) – The current form.

More information

See Gravity Forms Docs: gform_print_styles

Examples

Add a custom stylesheet to a specific form

This example adds the custom stylesheet print_entry.css to the print entry page when the form ID is 1.

add_filter('gform_print_styles', 'add_styles', 10, 2);

function add_styles($value, $form) {
    if ($form['id'] != 1) {
        return $value;
    }

    wp_register_style('print_entry', get_template_directory_uri() . '/print_entry.css');
    return array('print_entry');
}

Add a custom stylesheet to multiple forms

This example adds the custom stylesheet print_entry.css to the print entry page when the form ID is 1 or 6.

add_filter('gform_print_styles', 'add_styles', 10, 2);

function add_styles($value, $form) {
    $forms = array('1', '6');

    if (!in_array($form['id'], $forms)) {
        return $value;
    }

    wp_register_style('print_entry', get_template_directory_uri() . '/print_entry.css');
    return array('print_entry');
}

Placement

This code should be placed in the functions.php file of your active theme.

Source Code

This filter is located in print-entry.php.