Determine a network by its domain and path.


apply_filters( 'pre_get_network_by_path', (null) $null, (string) $domain, (string) $path, (int|null) $segments, (array) $paths ); 

This allows one to short-circuit the default logic, perhaps by replacing it with a routine that is more optimal for your setup.

Return null to avoid the short-circuit. Return false if no network can be found at the requested domain and path. Otherwise, return an object from wp_get_network().

Parameters (5)

0. $null (null) => null
Network value to return by path.
1. $domain (string)
The requested domain.
2. $path (string)
The requested path, in full.
3. $segments (int|null)
The suggested number of paths to consult. Default null, meaning the entire path was to be consulted.
4. $paths (array)
The paths to search for, based on $path and $segments.


To run the hook, copy the example below.
  1. $null = apply_filters( 'pre_get_network_by_path', $null, $domain, $path, $segments, $paths ); 
  3. if ( !empty( $null ) ) { 
  5. // everything has led up to this point... 
The following example is for adding a hook callback.
  1. // define the pre_get_network_by_path callback 
  2. function filter_pre_get_network_by_path( $null, $domain, $path, $segments, $paths ) { 
  3. // make filter magic happen here... 
  4. return $null
  5. }; 
  7. // add the filter 
  8. add_filter( 'pre_get_network_by_path', 'filter_pre_get_network_by_path', 10, 5 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'pre_get_network_by_path', 'filter_pre_get_network_by_path', 10, 5 ); 

Defined (1)

The filter is defined in the following location(s).

  1. $pre = apply_filters( 'pre_get_network_by_path', null, $domain, $path, $segments, $paths );