Turn is_blog_user() into a wrapper around is_user_member_of_blog() and deprecate. Make user_id optional for is_user_member_of_blog(). Props SergeyBiryukov. fixes #16702

git-svn-id: http://svn.automattic.com/wordpress/trunk@19016 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2011-10-19 22:35:15 +00:00
parent db86ea12d4
commit b957c72f9a
3 changed files with 37 additions and 36 deletions

View File

@ -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 );
}

View File

@ -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.
*

View File

@ -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;
}
/**