WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Difference between revisions of "Plugin API/Filter Reference/show admin bar"

(Changed admin bar to toolbar)
(Example Usage)
Line 5: Line 5:
   
 
== Example Usage ==
 
== Example Usage ==
  +
'''Note:''' The examples below should be called immediately upon plugin load or placed in theme's <tt>functions.php</tt> file.
  +
 
This code would turn the display status of the Toolbar to off.
 
This code would turn the display status of the Toolbar to off.
 
<pre>
 
<pre>

Revision as of 10:41, 31 August 2012

Description

The show_admin_bar filter toggles the display status of the Toolbar for the front side of your website (you cannot turn off the toolbar on the WordPress dashboard anymore).

Note: The Admin Bar is replaced with the Toolbar since WordPress Version 3.3.

Example Usage

Note: The examples below should be called immediately upon plugin load or placed in theme's functions.php file.

This code would turn the display status of the Toolbar to off.

add_filter( 'show_admin_bar', '__return_false' );

Alternatively, you could write it into a full fledged function.

function my_function_admin_bar(){
    return false;
}
add_filter( 'show_admin_bar' , 'my_function_admin_bar');

This would hide the Toolbar for all users except Administrators.

function my_function_admin_bar($content) {
	return ( current_user_can("administrator") ) ? $content : false;
}
add_filter( 'show_admin_bar' , 'my_function_admin_bar');