• Resolved consumedesign

    (@consumedesign)


    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!

Viewing 15 replies - 16 through 30 (of 30 total)
  • 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.

    Thread Starter consumedesign

    (@consumedesign)

    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.

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

    Thread Starter consumedesign

    (@consumedesign)

    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) {

    Thread Starter consumedesign

    (@consumedesign)

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

    @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.

    Thread Starter consumedesign

    (@consumedesign)

    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…

    Thread Starter consumedesign

    (@consumedesign)

    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');

    @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’.

    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.

    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

    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.

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

    @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;}

Viewing 15 replies - 16 through 30 (of 30 total)
  • The topic ‘Admin Bar for 3.1’ is closed to new replies.