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"

(Example Usage)
m (Example Usage)
Line 15: Line 15:
 
<pre>
 
<pre>
 
function my_function_admin_bar(){
 
function my_function_admin_bar(){
return false;
+
return false;
 
}
 
}
 
add_filter( 'show_admin_bar' , 'my_function_admin_bar');
 
add_filter( 'show_admin_bar' , 'my_function_admin_bar');

Revision as of 10:42, 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');