* Return empty arrays instead of false for all conditions in get_blogs_of_user().

* When deleting a user, use a delete_metadata_by_mid() loop over the meta so that the meta cache is cleared.
* Use remove_user_from_blog() for DRYness.

Props nacin, duck_
Fixes #19500


git-svn-id: https://develop.svn.wordpress.org/trunk@20581 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2012-04-24 22:13:47 +00:00
parent f55dbdbd27
commit d3571040fb
3 changed files with 15 additions and 13 deletions

View File

@@ -652,7 +652,7 @@ function get_users( $args = array() ) {
*
* @param int $user_id User ID
* @param bool $all Whether to retrieve all blogs, or only blogs that are not marked as deleted, archived, or spam.
* @return array A list of the user's blogs. False if the user was not found or an empty array if the user has no blogs.
* @return array A list of the user's blogs. An empty array if the user doesn't exist or belongs to no blogs.
*/
function get_blogs_of_user( $user_id, $all = false ) {
global $wpdb;
@@ -661,11 +661,11 @@ function get_blogs_of_user( $user_id, $all = false ) {
// Logged out users can't have blogs
if ( empty( $user_id ) )
return false;
return array();
$keys = get_user_meta( $user_id );
if ( empty( $keys ) )
return false;
return array();
if ( ! is_multisite() ) {
$blog_id = get_current_blog_id();
@@ -745,10 +745,7 @@ function is_user_member_of_blog( $user_id = 0, $blog_id = 0 ) {
$blog_id = get_current_blog_id();
$blogs = get_blogs_of_user( $user_id );
if ( is_array( $blogs ) )
return array_key_exists( $blog_id, $blogs );
else
return false;
return array_key_exists( $blog_id, $blogs );
}
/**