Codex

Function Reference/get user option

Contents

Description

Retrieve user option that can be either global, user, or blog.

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 non-global name, then the global name, and if it still doesn't find it, it will try the blog option. The option can either be modified or set by a plugin.

Usage

<?php get_user_option$option$user ?>

Parameters

$option
(string) (required) User option name.
Default: None
$user
(integer) (optional) User ID.
Default: 0

Return Values

(mixed) 
Option value on success, false on failure

Examples

<?php
	$bar = get_user_option( 'show_admin_bar_front', get_current_user_id() );
	if(  $bar == 'true' ) {
		echo 'The admin bar is enabled';
	} else {
		echo 'The admin bar is disabled';
	}
?>

Notes

  • Uses: apply_filters() Calls 'get_user_option_$option' hook with result, option parameter, and user data object.
  • Uses global: (object) $wpdb WordPress database object for queries.
  • The $check_blog_options parameter was deprecated in WordPress 3.0.

Change Log

Since: 2.0.0

Source File

get_user_option() is located in wp-includes/user.php.

Related

See also index of Function Reference and index of Template Tags.