The gform_toolbar_menu filter allows you to modify the links displayed in the Gravity Forms toolbar.
Usage
add_filter('gform_toolbar_menu', 'my_custom_function');
Parameters
- $menu_items(array): An array of menu items and their properties.
- $form_id(integer): The ID of the form for which the toolbar is being displayed.
More information
See Gravity Forms Docs: gform_toolbar_menu
Examples
Add a custom link to the Gravity Forms Toolbar
This example shows how to add a custom link to the Gravity Forms Toolbar, which will be displayed on the Form Editor, Form Settings, and Entries views.
add_filter('gform_toolbar_menu', 'my_custom_toolbar', 10, 2);
function my_custom_toolbar($menu_items, $form_id) {
$menu_items['my_custom_link'] = array(
'label' => 'My Custom Link', // the text to display on the menu for this link
'title' => 'My Custom Link', // the text to be displayed in the title attribute for this link
'url' => self_admin_url('admin.php?page=my_custom_page&id=' . $form_id), // the URL this link should point to
'menu_class' => 'gf_form_toolbar_custom_link', // optional, class to apply to menu list item (useful for providing a custom icon)
'link_class' => rgget('page') == 'my_custom_page' ? 'gf_toolbar_active' : '', // class to apply to link (useful for specifying an active style when this link is the current page)
'capabilities' => array('gravityforms_edit_forms'), // the capabilities the user should possess in order to access this page
'priority' => 500 // optional, use this to specify the order in which this menu item should appear; if no priority is provided, the menu item will be appended to the end
);
return $menu_items;
}
This code adds a new link to the Gravity Forms Toolbar with the label “My Custom Link”, pointing to a custom admin page with the provided form ID. The link will only be accessible to users with the gravityforms_edit_forms capability, and it will have an active style when the custom page is being viewed.