How to Enable the WordPress Admin Bar only for admins

Shortlink:

Hi today i will tech you how to Enable the WordPress Admin Bar only for admins , without plugin.

go to your active theme folder then open your functions.php page on any editor, like: notepad++ and past this code in functions.php.

If the user can not manage options, then do not show them the admin bar.


/*
* Enable the WordPress Admin Bar only for admins
*/
if ( !current_user_can( 'manage_options' ) ) {
remove_action( 'init', '_wp_admin_bar_init' );
}

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!