Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#39764 closed defect (bug) (invalid)

'pre_get_site_by_path' filter is called before plugin API is loaded

Reported by: veraxus's profile Veraxus Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.6
Component: Bootstrap/Load Keywords:
Focuses: multisite Cc:


The pre_get_site_by_path hook is called during the MS initialization process before the plugin API is loaded, which unfortunately means that this hook is orphaned and cannot be used.

Use case: Configure MS to allow multiple network TLDs, e.g. and – however, MS will return a DB connection error if the requested/defined domain does not match a site registered in the wp_blogs table. In attempting to use this hook to forcibly fetch the correct site is impossible because plugins are not available before this hook is executed.

Change History (1)

#1 @johnbillion
7 years ago

  • Focuses multisite added
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

This filter is one of a few which are applied very early on during the bootstrap process of WordPress Multisite, before the current site has been determined.

This filter fires before plugins are loaded, but it can be used within a custom wp-content/sunrise.php file. For example:

add_filter( 'pre_get_site_by_path', function( $site, $domain, $path, $segments, $paths ) {

	return WP_Site::get_instance( rand( 1, 10 ) );

}, 10, 5 );
Note: See TracTickets for help on using tickets.