mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-09 23:24:34 +00:00
Multisite: Add $network_id parameter to get_user_count().
The `get_user_count()` function returns the number of active users on a network, which is stored in a `user_count` network option. Since `get_network_option()` supports retrieving options from other networks than the current one, `get_user_count()` can now make use of that feature. Fixes #37866. git-svn-id: https://develop.svn.wordpress.org/trunk@40371 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -205,6 +205,35 @@ class Tests_Multisite_Network extends WP_UnitTestCase {
|
||||
$this->assertSame( count( self::$different_site_ids ), $site_count );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 37866
|
||||
*/
|
||||
public function test_get_user_count_on_different_network() {
|
||||
global $current_site, $wpdb;
|
||||
|
||||
wp_update_network_user_counts();
|
||||
$current_network_user_count = get_user_count();
|
||||
|
||||
// switch_to_network()...
|
||||
$orig_network_id = $current_site->id;
|
||||
$orig_wpdb_network_id = $wpdb->siteid;
|
||||
$current_site->id = self::$different_network_id;
|
||||
$wpdb->siteid = self::$different_network_id;
|
||||
|
||||
// Add another user to fake the network user count to be different.
|
||||
wpmu_create_user( 'user', 'pass', 'email' );
|
||||
|
||||
wp_update_network_user_counts();
|
||||
|
||||
// restore_current_network()...
|
||||
$current_site->id = $orig_network_id;
|
||||
$wpdb->siteid = $orig_wpdb_network_id;
|
||||
|
||||
$user_count = get_user_count( self::$different_network_id );
|
||||
|
||||
$this->assertEquals( $current_network_user_count + 1, $user_count );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 22917
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user