Add optional user_id arg.

git-svn-id: https://develop.svn.wordpress.org/trunk@3298 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2005-12-13 03:46:08 +00:00
parent 73edfc7c20
commit b1b88e415f
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 );
}