bp_get_admin_bar_pref( string $context, int $user )
Retrieve the Toolbar display preference of a user based on context.
Description
This is a direct copy of WP’s private _get_admin_bar_pref()
Parameters
- $context
-
(Required) Context of this preference check. 'admin' or 'front'.
- $user
-
(Optional) ID of the user to check. Default: 0 (which falls back to the logged-in user's ID).
Return
(bool) True if the toolbar should be showing for this user.
Source
File: bp-core/bp-core-buddybar.php
function bp_get_admin_bar_pref( $context, $user = 0 ) { $pref = get_user_option( "show_admin_bar_{$context}", $user ); if ( false === $pref ) return true; return 'true' === $pref; }
Changelog
Version | Description |
---|---|
BuddyPress 1.5.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.