The gform_load_admin_scripts_globally filter allows you to control the loading of Gravity Forms JavaScript bundles across all admin screens in WordPress.
Usage
To use this filter, add the following code to your theme’s functions.php
file or a custom plugin:
add_filter('gform_load_admin_scripts_globally', 'your_function_name');
Replace your_function_name
with your desired function name.
Parameters
$load_scripts
(bool): Determines whether to load admin scripts globally. Default is true.
More information
See Gravity Forms Docs: gform_load_admin_scripts_globally
Examples
Disable global admin script loading
Prevent loading of Gravity Forms admin scripts globally:
add_filter('gform_load_admin_scripts_globally', 'disable_global_admin_scripts'); function disable_global_admin_scripts() { return false; }
Load admin scripts globally only for specific users
Load Gravity Forms admin scripts globally only for users with a specific role:
add_filter('gform_load_admin_scripts_globally', 'load_scripts_for_specific_role'); function load_scripts_for_specific_role($load_scripts) { if (current_user_can('editor')) { return true; } return $load_scripts; }
Load admin scripts globally only on specific admin pages
Load Gravity Forms admin scripts globally only on specific admin pages:
add_filter('gform_load_admin_scripts_globally', 'load_scripts_on_specific_pages'); function load_scripts_on_specific_pages($load_scripts) { $screen = get_current_screen(); if ($screen->id === 'my_custom_page') { return true; } return $load_scripts; }
Load admin scripts globally only for specific forms
Load Gravity Forms admin scripts globally only for specific forms:
add_filter('gform_load_admin_scripts_globally', 'load_scripts_for_specific_forms', 10, 2); function load_scripts_for_specific_forms($load_scripts, $form) { if ($form['id'] === 1) { return true; } return $load_scripts; }
Load admin scripts globally based on a custom condition
Load Gravity Forms admin scripts globally based on a custom condition:
add_filter('gform_load_admin_scripts_globally', 'load_scripts_based_on_custom_condition'); function load_scripts_based_on_custom_condition($load_scripts) { if (my_custom_condition()) { return true; } return $load_scripts; } function my_custom_condition() { // your custom code here return true; }