diff --git wp-includes/user.php wp-includes/user.php
index 9f7cf75..f6e5662 100644
|
|
function get_blogs_of_user( $user_id, $all = false ) { |
1234 | 1234 | * @return bool |
1235 | 1235 | */ |
1236 | 1236 | function is_user_member_of_blog( $user_id = 0, $blog_id = 0 ) { |
1237 | | $user_id = (int) $user_id; |
1238 | | $blog_id = (int) $blog_id; |
| 1237 | global $wpdb; |
1239 | 1238 | |
1240 | | if ( empty( $user_id ) ) |
1241 | | $user_id = get_current_user_id(); |
| 1239 | if( ! is_multisite() ) |
| 1240 | return true; |
1242 | 1241 | |
1243 | | if ( empty( $blog_id ) ) |
1244 | | $blog_id = get_current_blog_id(); |
| 1242 | $user_id = (int) $user_id; |
| 1243 | $blog_id = (int) $blog_id; |
| 1244 | |
| 1245 | if ( empty( $user_id ) ) |
| 1246 | $user_id = get_current_user_id(); |
| 1247 | |
| 1248 | //Technically not needed, but does save calls to get_blog_details and get_user_meta |
| 1249 | //in the event that the function is called when a user isn't logged in |
| 1250 | if ( empty( $user_id ) ) |
| 1251 | return false; |
| 1252 | |
| 1253 | if ( empty( $blog_id ) ) |
| 1254 | $blog_id = get_current_blog_id(); |
| 1255 | |
| 1256 | $blog = get_blog_details( $blog_id ); |
| 1257 | |
| 1258 | if( ! $blog || ! isset( $blog->domain ) || $blog->archived || $blog->spam || $blog->deleted ) |
| 1259 | return false; |
| 1260 | |
| 1261 | $keys = get_user_meta( $user_id ); |
| 1262 | if ( empty( $keys ) ) |
| 1263 | return false; |
| 1264 | |
| 1265 | //no underscore before capabilities in $base_capabilities_key |
| 1266 | $base_capabilities_key = $wpdb->base_prefix . 'capabilities'; |
| 1267 | $site_capabilities_key = $wpdb->base_prefix . $blog_id . '_capabilities'; |
| 1268 | |
| 1269 | if ( isset( $keys[ $base_capabilities_key ] ) && defined( 'MULTISITE' ) && $blog_id == 1 ) |
| 1270 | return true; |
| 1271 | |
| 1272 | if ( isset( $keys[ $site_capabilities_key ] ) ) |
| 1273 | return true; |
1245 | 1274 | |
1246 | | $blogs = get_blogs_of_user( $user_id ); |
1247 | | return array_key_exists( $blog_id, $blogs ); |
| 1275 | return false; |
1248 | 1276 | } |
1249 | 1277 | |
1250 | 1278 | /** |