Add optional user_id arg.

git-svn-id: http://svn.automattic.com/wordpress/trunk@3298 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2005-12-13 03:46:08 +00:00
parent f588d966bd
commit f2d7c06c6d
1 changed files with 11 additions and 5 deletions

View File

@ -300,12 +300,18 @@ function get_option($option) {
return get_settings($option);
}
function get_user_option( $option ) {
function get_user_option( $option, $user = 0 ) {
global $wpdb, $current_user;
if ( isset( $current_user->{$wpdb->prefix . $option} ) ) // Blog specific
return $current_user->{$wpdb->prefix . $option};
elseif ( isset( $current_user->{$option} ) ) // User specific and cross-blog
return $current_user->{$option};
if ( empty($user) )
$user = $current_user;
else
$user = get_userdata($user);
if ( isset( $user->{$wpdb->prefix . $option} ) ) // Blog specific
return $user->{$wpdb->prefix . $option};
elseif ( isset( $user->{$option} ) ) // User specific and cross-blog
return $user->{$option};
else // Blog global
return get_option( $option );
}