I would like to limit the +New admin menu to only show the single sub menu Event (“Veranstaltung”).
Basically the users are allowed to create other items as well but not from that +New menu.

I already tried it with “Adminimize” plugin as this can remove the other items but it will leave the new media link intact once you click directly “+New”.

I already added some other logic to remove items from the left admin menu like:
function remove_menus() {
remove_menu_page('edit.php?post_type=mdocs-posts');
}
add_action('admin_menu', 'remove_menus');
But I can’t get how to modify the +New. Any hints?
Thank you!
To hide everything (menu and submenu)-
function wpse_260669_remove_new_content(){
global $wp_admin_bar;
$wp_admin_bar->remove_menu( 'new-content' );
}
add_action( 'wp_before_admin_bar_render', 'wpse_260669_remove_new_content' );
To hide specific menu/submenu item(s)-
function wpse_260669_remove_new_content_items(){
global $wp_admin_bar;
$wp_admin_bar->remove_menu( 'new-post' ); // hides post CPT
$wp_admin_bar->remove_menu( 'new-product' ); // hides product CPT
$wp_admin_bar->remove_menu( 'new-page' ); // hides page CPT
$wp_admin_bar->remove_menu( 'new-media' ); // hides media
}
add_action( 'wp_before_admin_bar_render', 'wpse_260669_remove_new_content_items' );
So, the basic rule is-
function your_boo_bar_function() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu( 'your-unique-menu-id' );
}
add_action( 'wp_before_admin_bar_render', 'your_boo_bar_function' );
Add a new menu-
function wpse_260669_add_menu(){
global $wp_admin_bar;
$wp_admin_bar->add_node(
array(
'id' => 'google-menu',
'title' => 'Google',
'href' => 'http://google.com',
'parent' => 'new-content', // so, it'll be set as a child of 'new-content'. remove this to use this as a parent menu
'meta' => array( 'class' => 'my-custom-class' ),
)
);
}
add_action( 'wp_before_admin_bar_render', 'wpse_260669_add_menu' );
Update an existing menu-
If you want to update an existing menu item, just add a new item using the ID of your desired menu.
To update +New (‘content-new’), use this code-
function wpse_260669_update_menu(){
global $wp_admin_bar;
$wp_admin_bar->add_node(
array(
'id' => 'new-content', // id of an existing menu
'href' => 'your_new_url_goes_here', // set new URL
)
);
}
add_action( 'wp_before_admin_bar_render', 'wpse_260669_update_menu' );
How to get menu ID-
The easiest way is to inspect element with Firebug and take the ID. See this screenshot-

Navigate to your desired menu item and get the string next to wp-admin-bar-