Title: _get_admin_bar_pref
Published: April 25, 2014
Last modified: February 24, 2026

---

# _get_admin_bar_pref( string $context, int $user ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/_get_admin_bar_pref/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/_get_admin_bar_pref/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/_get_admin_bar_pref/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/_get_admin_bar_pref/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/_get_admin_bar_pref/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/_get_admin_bar_pref/?output_format=md#wp--skip-link--target)

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

Retrieves the admin bar display preference of a user.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/_get_admin_bar_pref/?output_format=md#parameters)󠁿

 `$context`stringrequired

Context of this preference check. Defaults to `'front'`. The `'admin'` preference
is no longer used.

`$user`intoptional

ID of the user to check, defaults to 0 for current user.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/_get_admin_bar_pref/?output_format=md#return)󠁿

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

## 󠀁[Source](https://developer.wordpress.org/reference/functions/_get_admin_bar_pref/?output_format=md#source)󠁿

    ```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;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/admin-bar.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/admin-bar.php#L1394)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/admin-bar.php#L1394-L1401)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/_get_admin_bar_pref/?output_format=md#related)󠁿

| Uses | Description | 
| [get_user_option()](https://developer.wordpress.org/reference/functions/get_user_option/)`wp-includes/user.php` |

Retrieves user option that can be either per Site or per Network.

  |

| Used by | Description | 
| [is_admin_bar_showing()](https://developer.wordpress.org/reference/functions/is_admin_bar_showing/)`wp-includes/admin-bar.php` |

Determines whether the admin bar should be showing.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/_get_admin_bar_pref/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.1.0](https://developer.wordpress.org/reference/since/3.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F_get_admin_bar_pref%2F)
before being able to contribute a note or feedback.