Change WordPress user roles and capabilities › Forums › How to or FAQ › How to block/hide items from the top bar of wordpress? › Reply To: How to block/hide items from the top bar of wordpress?
02/02/2017 at 14:14
#3318
Vladimir
Keymaster
In general, top admin menu bar menu is blocked automatically if its correspondent main admin menu item was blocked.
In order to block “Yoas SEO” just at top admin menu bar use this code:
add_action('wp_before_admin_bar_render', 'block_top_wp_seo');
function block_top_wp_seo() {
global $wp_admin_bar;
if (current_user_can('administrator')) {
return;
}
$wp_admin_bar->remove_menu('wpseo-menu');
}
Insert into the active theme functions.php file for the single site or setup as a “must use” plugin to aplly it globally to all sites.