wp_is_large_network( string $using = 'sites', int|null $network_id = null )

Whether or not we have a large network.


Description Description

The default criteria for a large network is either more than 10,000 users or more than 10,000 sites. Plugins can alter this criteria using the ‘wp_is_large_network’ filter.


Top ↑

Parameters Parameters

$using

(string) (Optional) 'sites or 'users'. Default is 'sites'.

Default value: 'sites'

$network_id

(int|null) (Optional) ID of the network. Default is the current network.

Default value: null


Top ↑

Return Return

(bool) True if the network meets the criteria for large. False otherwise.



Top ↑

Source Source

File: wp-includes/ms-functions.php

function wp_is_large_network( $using = 'sites', $network_id = null ) {
	$network_id = (int) $network_id;
	if ( ! $network_id ) {
		$network_id = get_current_network_id();
	}

	if ( 'users' == $using ) {
		$count = get_user_count( $network_id );
		/**
		 * Filters whether the network is considered large.
		 *
		 * @since 3.3.0
		 * @since 4.8.0 The `$network_id` parameter has been added.
		 *
		 * @param bool   $is_large_network Whether the network has more than 10000 users or sites.
		 * @param string $component        The component to count. Accepts 'users', or 'sites'.
		 * @param int    $count            The count of items for the component.
		 * @param int    $network_id       The ID of the network being checked.
		 */
		return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count, $network_id );
	}

	$count = get_blog_count( $network_id );
	/** This filter is documented in wp-includes/ms-functions.php */
	return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count, $network_id );
}

Top ↑

Changelog Changelog

Changelog
Version Description
4.8.0 The $network_id parameter has been added.
3.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Rami Yushuvaev

    Whether the network has more than 5,000 users/sites instead of 10,000:

    function custom_large_network( $is_large_network, $component, $count, $network_id ) {
        return ( $count > 5000);
    }
    add_filter( 'wp_is_large_network', 'custom_large_network', 10, 4 );

    Source: https://generatewp.com/snippet/9XaNVan/

  2. Skip to note 2 content
    Contributed by Rami Yushuvaev

    Whether the network has more than 5,000 users/sites instead of 10,000:

    function custom_large_network( $is_large_network, $component, $count, $network_id ) {
    	return 5;
    }
    add_filter( 'wp_is_large_network', 'custom_large_network', 10, 4 );

    Source: https://generatewp.com/snippet/9XaNVan/

You must log in before being able to contribute a note or feedback.