Change Global Capability for Toolbar Items of Toolbar Extras

Though not recommended, you can change the global capability to display any Toolbar items from Toolbar Extras plugin. This filter exists for developers or agency who use custom roles and capabilities to manage their (client) sites.

Please remember: most of the items displayed from third-party themes or plugins require the capabilities manage_options and/or edit_theme_options anyways – beyond the filtered capability shown below.

This code snippet goes into a core functionality plugin, or into Code Snippets.

if ( ! function_exists( 'tbex_filter_capability_all' ) ) :

	add_filter( 'tbex_filter_capability_all', 'tbex_filter_capability_all' );
	 * Toolbar Extras: Filter global capability for plugin's Toolbar items
	function tbex_filter_capability_all() {

		return 'your_custom_capability';

	}  // end function

endif;Code language: PHP (php)

Note: The returned capability string needs to be compatible with WordPress’ own security function sanitized_key(). Therefore it must be lowercase and can only contain letters, numbers, dashes and underscores.