pre_get_main_site_id
Filters the main site ID.
Returning a positive integer will effectively short-circuit the function.
Usage
add_filter( 'pre_get_main_site_id', 'wp_kama_pre_get_main_site_id_filter', 10, 2 );
/**
* Function for `pre_get_main_site_id` filter-hook.
*
* @param int|null $main_site_id If a positive integer is returned, it is interpreted as the main site ID.
* @param WP_Network $network The network object for which the main site was detected.
*
* @return int|null
*/
function wp_kama_pre_get_main_site_id_filter( $main_site_id, $network ){
// filter...
return $main_site_id;
}
- $main_site_id(int|null)
- If a positive integer is returned, it is interpreted as the main site ID.
- $network(WP_Network)
- The network object for which the main site was detected.
Changelog
| Since 4.9.0 | Introduced. |
Where the hook is called
pre_get_main_site_id
wp-includes/class-wp-network.php 230
$main_site_id = (int) apply_filters( 'pre_get_main_site_id', null, $this );