show_admin_bar() WordPress Function

The show_admin_bar() function is used to show or hide the WordPress admin bar on the front end of the site. By default, the admin bar is shown for all users.

show_admin_bar( bool $show ) #

Sets the display status of the admin bar.


Description

This can be called immediately upon plugin load. It does not need to be called from a function hooked to the ‘init’ action.


Top ↑

Parameters

$show

(bool)(Required)Whether to allow the admin bar to show.


Top ↑

More Information

This function should be called immediately upon plugin load or placed in the theme’s functions.php file.

This function will also affect the display of the Toolbar in the dashboard for WordPress versions prior to Version 3.3.


Top ↑

Source

File: wp-includes/admin-bar.php

function show_admin_bar( $show ) {
	global $show_admin_bar;
	$show_admin_bar = (bool) $show;
}


Top ↑

Changelog

Changelog
VersionDescription
3.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.