WordPress.org

Codex

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

Plugin API/Filter Reference/show admin bar

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

This filter is part of the function is_admin_bar_showing()

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

Parameters

$show_admin_bar
(bool) (required) Whether the admin bar should be shown.
Default: true

Examples

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

Change Log

Since: 3.1

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

Source Files

show_admin_bar is located in wp-includes/admin-bar.php

Related