bp_get_admin_bar_pref

Retrieve the Toolbar display preference of a user based on context.

Description

bp_get_admin_bar_pref( (string) $context, (int) $user = 0 ); 

This is a direct copy of WP's private _get_admin_bar_pref()

Parameters (2)

0. $context (string)
Context of this preference check. admin or front..
1. $user — Optional. (int)
ID of the user to check. Default: 0 (which falls back to the logged-in user's ID).

Usage

  1. if ( !function_exists( 'bp_get_admin_bar_pref' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-buddybar.php'; 
  3.  
  4. // Context of this preference check. 'admin' or 'front'. 
  5. $context = ''; 
  6.  
  7. // Optional. ID of the user to check. Default: 0 (which falls back to the logged-in user's ID). 
  8. $user = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_get_admin_bar_pref($context, $user); 
  12.  

Defined (1)

The function is defined in the following location(s).

/bp-core/bp-core-buddybar.php  
  1. function bp_get_admin_bar_pref( $context, $user = 0 ) { 
  2. $pref = get_user_option( "show_admin_bar_{$context}", $user ); 
  3. if ( false === $pref ) 
  4. return true; 
  5.  
  6. return 'true' === $pref;