Changeset 8587
- Timestamp:
- 07/10/2014 08:22:33 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/bp-blogs-functions.php
r8586 r8587 98 98 $wpdb->query( "TRUNCATE {$bp->blogs->table_name_blogmeta}" ); 99 99 100 // Loop through users of blogs and record them 101 foreach( (array) $blog_ids as $blog_id ) { 102 $users = get_users( array( 'blog_id' => $blog_id, 'fields' => 'ID' ) ); 103 $subscribers = get_users( array( 'blog_id' => $blog_id, 'fields' => 'ID', 'role' => 'subscriber' ) ); 104 105 if ( !empty( $users ) ) { 106 foreach ( (array) $users as $user ) { 107 // Don't record blogs for subscribers 108 if ( !in_array( $user, $subscribers ) ) { 109 bp_blogs_record_blog( $blog_id, $user, true ); 110 } 111 } 100 // Loop through users of blogs and record the relationship 101 foreach ( (array) $blog_ids as $blog_id ) { 102 103 // Get all users 104 $all_users = get_users( array( 105 'blog_id' => $blog_id, 106 'fields' => 'ID' 107 ) ); 108 109 // Get subscribers 110 $subscribers = get_users( array( 111 'blog_id' => $blog_id, 112 'fields' => 'ID', 113 'role' => 'subscriber' 114 ) ); 115 116 // Remove subscribers from users (for some legacy/wpcom reason?) 117 $users = array_values( array_diff( $all_users, $subscribers ) ); 118 119 // Reclaim some memory in the event there are many users 120 unset( $all_users, $subscribers ); 121 122 // Continue on if no users exist for this site (how did this happen?) 123 if ( empty( $users ) ) { 124 continue; 125 } 126 127 // Loop through users and record their relationship to this blog 128 foreach ( $users as $user ) { 129 bp_blogs_record_blog( $blog_id, $user, true ); 112 130 } 113 131 }
Note: See TracChangeset
for help on using the changeset viewer.