How to Remove My Sites Sub-Menu Options: Dashboard, New Post, Manage Comments and Visit Site

Shortlink:

How to Remove My Sites Sub-Menu Options: Dashboard, New Post, Manage Comments and Visit Site

 


/*
* Remove My Sites Sub-Menu Options: Dashboard, New Post, Manage Comments and Visit
Site
*/
function remove_mysites_links () {
global $wp_admin_bar;
foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
$menu_id_d = 'blog-' . $blog->userblog_id . '-d'; /*Dashboard var */
$menu_id_n = 'blog-' . $blog->userblog_id . '-n'; /* New Post var */
$menu_id_c = 'blog-' . $blog->userblog_id . '-c'; /* Manage Comments var */
$menu_id_v = 'blog-' . $blog->userblog_id . '-v'; /*Visit Site var */
$wp_admin_bar->remove_menu($menu_id_d); /*Remove Dashboard Link */
$wp_admin_bar->remove_menu($menu_id_n); /*Remove New Post Link */
$wp_admin_bar->remove_menu($menu_id_c); /*Remove Manage Comments Link */
$wp_admin_bar->remove_menu($menu_id_v); /*Remove Visit Site Link */
}
}
add_action( 'wp_before_admin_bar_render', 'remove_mysites_links' );

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!