Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_get_admin_bar_pref() WordPress Function

The get_admin_bar_pref() function is used to get the user's preference for whether to display the admin bar.

_get_admin_bar_pref( string $context = 'front', int $user ) #

Retrieves the admin bar display preference of a user.


Parameters

$context

(string)(Optional)Context of this preference check. Defaults to 'front'. The 'admin' preference is no longer used.

Default value: 'front'

$user

(int)(Optional) ID of the user to check, defaults to 0 for current user.


Top ↑

Return

(bool) Whether the admin bar should be showing for this user.


Top ↑

Source

File: wp-includes/admin-bar.php

function _get_admin_bar_pref( $context = 'front', $user = 0 ) {
	$pref = get_user_option( "show_admin_bar_{$context}", $user );
	if ( false === $pref ) {
		return true;
	}

	return 'true' === $pref;
}


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.