WordPress.org

Ready to get started?Download WordPress

Forums

Remove admin bar from dashboard? (8 posts)

  1. casper1
    Member
    Posted 2 years ago #

    Hello,
    Is it possible to hide the Admin bar in the dashboard for the non-admin users? I know the CSS trick to display none, but I'm looking to remove this so that the code is not generated in the page.

  2. NuBlue-Hosting
    Member
    Posted 2 years ago #

    Hi Casper1,

    If you find the file

    ./wp-includes/class-wp-admin-bar.php

    Then go to line 344 and find the following code:

    <div id="wpadminbar" class="<?php echo $class; ?>" role="navigation">
    			<div class="quicklinks">
    				<?php foreach ( $root->children as $group ) {
    					$this->_render_group( $group );
    				} ?>
    			</div>
    		</div>

    The above is responsible for displaying the bar. Further to this if you use the is_super_admin() function you can limit the display to only super admins. Something like:

    <?php
    
    if (is_super_admin())
    {
    
    /* Dashboard Code Here  */
    
    }
    
    ?>

    Would show code only for the 1 super admin user (you'll need to play with it a bit as the admin bar html code has multiple php open and close tags in it but hopefully that gives a gist of how to do it. Hope that helps :-).

  3. Digital Raindrops
    Member
    Posted 2 years ago #

    Add to you themes functions.php

    /* Get rid of the admin bar for other users by capability */
    if ( is_user_logged_in() && !current_user_can( 'manage_options' ) ) {
         add_filter('show_admin_bar', '__return_false');
    }

    Or:

    /* Get rid of the admin bar for other non admin users */
    if ( is_user_logged_in() && !is_admin() ) {
         add_filter('show_admin_bar', '__return_false');
    }

    HTH

    David

  4. Harrison O.
    Member
    Posted 2 years ago #

    Never change any WP core file unless you want to redo the work every time you update wordpress.

    There are many plugins available that will take care of that or just add the following code to your theme's function.php

    /* Disable the WordPress Admin Bar for all but admins. */
    if (!current_user_can('administrator')):
    show_admin_bar(false);
    endif;

    By this way, only administrators will have the admin bar.

  5. NuBlue-Hosting
    Member
    Posted 2 years ago #

    Thanks Harrison O that is a much better way of handling it :)

  6. Dinesh Karki
    Member
    Posted 2 years ago #

    You can use this plugin as well. Activate it and you are done.

    http://wordpress.org/extend/plugins/remove-admin-bar-for-client/

  7. Vavix
    Member
    Posted 2 years ago #

    I tried most of these things and plugins and nothing worked. I wanted to remove the admin bar since it is always fixed on top and sometimes causes visual bugs.

    The solution I found was to simply add your own css to functions.php and set the visibility to hidden like so:

    // hide admin bar
    function custom_admin_css() {
       echo '<style type="text/css">
               #wpadminbar {visibility:hidden}
             </style>';
    }
    
    add_action('admin_head', 'custom_admin_css');
  8. Shane G.
    Member
    Posted 2 years ago #

    Hi!

    You can use the Adminimize plugin that lets you hide unnecessary items from the WordPress administration menu, submenu and even the 'Dashboard', with forwarding to the Manage-page.

    Regards.

Topic Closed

This topic has been closed to new replies.

About this Topic