diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index aafe8735d2..07c89f2d28 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -2870,3 +2870,20 @@ function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) { $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); } } + +/** + * Checks if the current user belong to a given blog. + * + * @since MU + * @deprecated 3.3 + * @deprecated Use is_user_member_of_blog() + * @see is_user_member_of_blog() + * + * @param int $blog_id Blog ID + * @return bool True if the current users belong to $blog_id, false if not. + */ +function is_blog_user( $blog_id = 0 ) { + _deprecated_function( __FUNCTION__, '3.3', 'is_user_member_of_blog()' ); + + return is_user_member_of_blog( get_current_user_id(), $blog_id ); +} diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index 8ebb0698b0..3e6a6652f4 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -118,32 +118,6 @@ function get_active_blog_for_user( $user_id ) { } } -/** - * Find out whether a user is a member of a given blog. - * - * @since MU 1.1 - * @uses get_blogs_of_user() - * - * @param int $user_id The unique ID of the user - * @param int $blog Optional. If no blog_id is provided, current site is used - * @return bool - */ -function is_user_member_of_blog( $user_id, $blog_id = 0 ) { - $user_id = (int) $user_id; - $blog_id = (int) $blog_id; - - if ( $blog_id == 0 ) { - global $wpdb; - $blog_id = $wpdb->blogid; - } - - $blogs = get_blogs_of_user( $user_id ); - if ( is_array( $blogs ) ) - return array_key_exists( $blog_id, $blogs ); - else - return false; -} - /** * The number of active users in your installation. * diff --git a/wp-includes/user.php b/wp-includes/user.php index 768ea68d9d..e3ca1310fe 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -720,22 +720,32 @@ function get_blogs_of_user( $user_id, $all = false ) { } /** - * Checks if the current user belong to a given blog. + * Find out whether a user is a member of a given blog. * - * @since MU + * @since MU 1.1 + * @uses get_blogs_of_user() * - * @param int $blog_id Blog ID - * @return bool True if the current users belong to $blog_id, false if not. + * @param int $user_id The unique ID of the user + * @param int $blog Optional. If no blog_id is provided, current site is used + * @return bool */ -function is_blog_user( $blog_id = 0 ) { - global $wpdb; +function is_user_member_of_blog( $user_id = 0, $blog_id = 0 ) { + $user_id = (int) $user_id; + $blog_id = (int) $blog_id; - if ( ! $blog_id ) + if ( empty( $user_id ) ) + $user_id = get_current_user_id(); + + if ( empty( $blog_id ) ) { + global $wpdb; $blog_id = $wpdb->blogid; + } - $blogs = get_blogs_of_user( get_current_user_id() ); - - return is_array( $blogs ) && array_key_exists( $blog_id, $blogs ); + $blogs = get_blogs_of_user( $user_id ); + if ( is_array( $blogs ) ) + return array_key_exists( $blog_id, $blogs ); + else + return false; } /**