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