WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Admin Bar for 3.1 (31 posts)

  1. consumedesign
    Member
    Posted 3 years ago #

    I like the addition of the admin bar, but is there any way to remove specific items from it... for example I don't use comments on my site so I have no need for it in the bar. As well as appearance since I'll never change the theme nor the widgets (don't use those either). thanks!

  2. Jonas Grumby
    Member
    Posted 3 years ago #

    I agree that it's kind of an imposition especially on sites that require a login. You can turn it off under Users > Your Profile and there is also code that you can add to the functions.php of your theme to turn it off globally, but right now those are the only options AFAIK.

  3. consumedesign
    Member
    Posted 3 years ago #

    Ya I added the remove code in my functions.php file but I would rather keep it. It's kinda nice to see the page, see an error, and goto the edit page right from it. It's very handy but filled with things I don't care to look at or would ever use.

  4. consumedesign
    Member
    Posted 3 years ago #

    I'm also digging the custom menus but wish I would have seen it before building a new client site... they would have liked it instead of using the exclude page plug in that I used. Ha, oh well... next time maybe.

  5. Jonas Grumby
    Member
    Posted 3 years ago #

    It's also very easy to have an "edit this page" link on the page which only appears if you are logged in and have edit capabilities. Personally I don't think I need the admin bar and I think it tends to homogenize all WP sites. Of course if you are running a business you pay a lot of money to have a unique look. I'm glad that there are ways to turn it off.

  6. Jonas Grumby
    Member
    Posted 3 years ago #

    It's very easy to exclude pages from the menu without a plugin. The custom menus thing is more about being able to add pages, especially pages that are outside of your WordPress installation.

  7. ClaytonJames
    Member
    Posted 3 years ago #

    I have a high traffic intra-net site where users really have no need for the Admin Bar at the moment. I disabled it globally using Ozh's plugin.

    Disable Admin Bar

    That was just one more option in my case. Works like a charm so far.

  8. consumedesign
    Member
    Posted 3 years ago #

    No need for a plug in... just toss this in your functions.php:
    add_filter( 'show_admin_bar', '__return_false' );

  9. ClaytonJames
    Member
    Posted 3 years ago #

    That's all the plugin actually is as well, just the same filter. I was being the lazy sort today because I let them use a theme switcher for personalization, and didn't feel like editing multiple theme function files. The plugin was a hard and fast solution. Plus, it's just so darned cool!

    :-)

  10. The plugin is 'better' since it's not theme dependent.

    If you run MultiSite, OR single site actually, put it in the mu-plugins folder (if you don't have it, make it on the same level as the plugins folder). That will AUTOMATICALLY run on your website, and never be able to be turned off.

  11. Jonas Grumby
    Member
    Posted 3 years ago #

    So how do you get to be a "Half-Elf Support Rogue"?

  12. First you have to sneak up on the code ninjas or team pirates and stab their pockets.

  13. Jonas Grumby
    Member
    Posted 3 years ago #

    Sounds exciting. I just try to steer people in the right direction if possible.

  14. rubinsandwich
    Member
    Posted 3 years ago #

    Does anyone know a simple way to disable the Admin Bar for "subscribers" only?

    I actually like it for my own use, but would really rather have it hidden for the vast number of subscribers who would not use any of its functionality.

    Thanks!

  15. consumedesign
    Member
    Posted 3 years ago #

    function yoast_disable_admin_bar() {
    if ( 2 == get_current_user_id() ) {
    add_filter( 'show_admin_bar', '__return_false' );
    }
    }
    add_action( 'init', 'yoast_disable_admin_bar' , 9 );

    I think? It would go into your functions.php... I'm using it now.

  16. rubinsandwich
    Member
    Posted 3 years ago #

    @consumerdesign, that disables it for a specific user (whomever has the user ID of 2 in the example). I'm looking it do it based on the user role.

    Thanks to you, I found that Yoast article on the issue and it got me on the right track. I'm thinking something along these lines (notice bold section):

    <?php function yoast_hide_admin_bar_settings() {
    ?>
    <style type="text/css">
    .show-admin-bar {
    display: none;
    }
    </style>
    <?php
    }

    function yoast_disable_admin_bar() {
    if (current_user_can( 'publish_posts' )){
    add_filter( 'show_admin_bar', '__return_false' );
    }
    }
    add_action( 'init', 'yoast_disable_admin_bar' , 9 );

    Any thoughts?

  17. rubinsandwich
    Member
    Posted 3 years ago #

    OK, figured it out and seems to be working with my testing. Let me know if anyone sees any glaring problems with this.

    /* Disable the Admin Bar for subscribers. */
    
    function my_function_admin_bar(){
    
    if (current_user_can('publish_posts')) {
    return true;}
    else {return false;
       }
    
    }
    add_filter( 'show_admin_bar' , 'my_function_admin_bar');

    *Technically this disables it for "contributors" as well, but in actuality, I want it hidden for anyone who doesn't post articles. You should be able to tailor it to your needs based on the user role privileges.

  18. consumedesign
    Member
    Posted 3 years ago #

    hm oh ya, ha... I thought I checked it and it removed it for everyone. Oh well, I got it from somewhere but it looks like you have it anyhow.

  19. messy-h
    Member
    Posted 3 years ago #

    Ummm you are aware theres an option to enable/disable the bar in the user settings (per user), yes?

  20. consumedesign
    Member
    Posted 3 years ago #

    Can't you also do something like:

    function my_function_admin_bar(){
    	global $userdata;
    	if($userdata->user_level == 1) {
    		return false;
    		} else {
    		return true;
      	 }
    }
    add_filter( 'show_admin_bar' , 'my_function_admin_bar');

    so in turn just admins would be

    if($userdata->user_level < 9) {
  21. consumedesign
    Member
    Posted 3 years ago #

    @messy-h: ya but they can go back in and edit that correct?

  22. rubinsandwich
    Member
    Posted 3 years ago #

    @messy-h - Yes I am, but this turns it off by default and it solves it with one block of code once as opposed to switching it off 700+ times for all of my subscriber accounts.

    @consumedesign - I don't see why that wouldn't work. I went with the curent_user_can, since the level method is depreciated (as of 3.0). I just picked an appropriate capability from here.

    I have custom profile pages, so the Admin Box checkbox option doesn't appear at all for my users. I'm not sure how the individual selection would be affected by this mod.

  23. consumedesign
    Member
    Posted 3 years ago #

    Ahh I forget they are deprecated... though I have 3.1 and still working fine for me. I just don't like the current_user_can and would rather have someone tagged as a number ha...

  24. consumedesign
    Member
    Posted 3 years ago #

    This would be a better way to go I guess:

    function my_function_admin_bar(){
    	if (current_user_can('manage_network')) {
    		return true;
    		} else {
    		return false;
      	 }
    }
    add_filter( 'show_admin_bar' , 'my_function_admin_bar');
  25. Jonas Grumby
    Member
    Posted 3 years ago #

    @rubinsandwich: Admin Bar Disabler

    Disable the WP Admin Bar in 3.1+ entirely, or only for roles and capabilities which aren't in the 'whitelist' or that have been specifically excluded in the 'blacklist'.

  26. rubinsandwich
    Member
    Posted 3 years ago #

    Nice! Looks like that just got posted yesterday. I'll give it a shot.

    The obvious advantage of a plugin (other than simplicity) is that it won't get overwritten during theme updates.

  27. Ghodmode
    Member
    Posted 3 years ago #

    The bar affects the layout and presentation of the site. This should be in the hands of the site administrator, not the individual users.

    It was pretty easy to add the line to functions.php, but that's a hack. There should be an option in the Site Admin to disable it site-wide.

    -- Ghodmode

  28. Naz
    Member
    Posted 3 years ago #

    Thanks for the code, guys. I hope the WordPress devs will add a feature to disable this or someone creates a plugin to do this.

  29. Wes Todd
    Member
    Posted 3 years ago #

    Most of the main questions are answered in this blog post, and it just so happens to be my blog...
    http://wesleytodd.com/wp31-admin-bar-removal-styling

  30. summerchilde
    Member
    Posted 3 years ago #

    @consumedesign

    You can hide parts of the admin bar with CSS. To remove the comments and the appearance options add this to your stylesheet:

    #wp-admin-bar-comments {display:none;}
    #wp-admin-bar-appearance {display:none;}

Topic Closed

This topic has been closed to new replies.

About this Topic