get_user_option()
Retrieve user option that can be either per Site or per Network.
If the user ID is not given, then the current user will be used instead. If the user ID is given, then the user data will be retrieved. The filter for the result, will also pass the original option name and finally the user data object as the third parameter.
The option will first check for the per site name and then the per Network name.
Uses: get_userdata()
Hooks from the function
Return
Mixed
. User option value on success, false on failure.
Usage
get_user_option( $option, $user, $deprecated );
- $option(string) (required)
- User option name.
- $user(int)
- User ID.
- $deprecated(string)
- Use get_option() to check for an option in the options table.
Default: ''
Examples
#1 Usage Example
Let's check whether the user has the ability to use the admin bar in the front of the site:
$bar = get_user_option( 'show_admin_bar_front', get_current_user_id() ); if ( $bar ) { echo 'Admin bar is enabled'; } else { echo 'The admin bar is disabled'; }
Notes
- Global. wpdb. $wpdb WordPress database abstraction object.
Changelog
Since 2.0.0 | Introduced. |