apply_filters( 'show_admin_bar', bool $show_admin_bar )

Filters whether to show the admin bar.


Description Description

Returning false to this hook is the recommended way to hide the admin bar. The user’s display preference is used for logged in users.


Top ↑

Parameters Parameters

$show_admin_bar

(bool) Whether the admin bar should be shown. Default false.


Top ↑

More Information More Information

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.


Top ↑

Source Source

File: wp-includes/admin-bar.php

View on Trac



Top ↑

Changelog Changelog

Changelog
Version Description
3.1.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by stevenlinx

    Examples migrated from Codex.

    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.

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

    This would hide the Toolbar for all users except Administrators.

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

You must log in before being able to contribute a note or feedback.