_get_admin_bar_pref

Retrieve the admin bar display preference of a user.

Description

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

Parameters (2)

0. $context — Optional. (string) => 'front'
Context of this preference check. Defaults to front.. The admin preference is no longer used.
1. $user — Optional. (int)
ID of the user to check, defaults to 0 for current user.

Usage

  1. if ( !function_exists( '_get_admin_bar_pref' ) ) { 
  2. require_once ABSPATH . WPINC . '/admin-bar.php'; 
  3.  
  4. // Context of this preference check. Defaults to 'front'. The 'admin' 
  5. // preference is no longer used. 
  6. $context = 'front'; 
  7.  
  8. // Optional. ID of the user to check, defaults to 0 for current user. 
  9. $user = -1; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = _get_admin_bar_pref($context, $user); 
  13.  

Defined (1)

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

/wp-includes/admin-bar.php  
  1. function _get_admin_bar_pref( $context = 'front', $user = 0 ) { 
  2. $pref = get_user_option( "show_admin_bar_{$context}", $user ); 
  3. if ( false === $pref ) 
  4. return true; 
  5.  
  6. return 'true' === $pref;