
Action Hook since 2.8.0
muplugins_loaded
Fires right after mu-plugins load — the true first hook of the request
Description
muplugins_loaded is the earliest action in the entire WordPress bootstrap — it fires right after must-use (mu-plugins) and network-activated plugins are loaded, before a single regular plugin has run. Almost nobody hooks it, which is exactly why it makes a great trivia question.
When it runs
Inside wp-settings.php, immediately after requiring files from wp-content/mu-plugins/ (and network-activated plugins on multisite), before regular active plugins are loaded.
Signature
do_action( 'muplugins_loaded' );Examples
Basic
add_action( 'muplugins_loaded', function() {
error_log( 'Bootstrap started.' );
} );Confirm this is the earliest point custom code can hook into.
Real case
add_action( 'muplugins_loaded', function() {
if ( ! defined( 'MY_PLUGIN_BOOT_TIME' ) ) {
define( 'MY_PLUGIN_BOOT_TIME', microtime( true ) );
}
} );Mark a precise bootstrap-start timestamp for later performance measurement, before anything else has run.
Edge case
add_action( 'muplugins_loaded', function() {
// Regular plugins are NOT loaded yet — calling a function
// defined by a normal plugin here will fatal-error.
} );Nothing from a normal (non-mu) plugin exists yet at this point — only mu-plugins and WordPress core itself.
Common Use Cases
- Bootstrap code that must run before any regular plugin
- Define constants needed by plugins loaded afterward
- Multisite: react to network-activated plugins having loaded
- Mark a precise start-of-bootstrap timestamp for performance profiling
Common mistakes
- Assuming this hook only fires when mu-plugins exist — it fires on every request regardless, empty mu-plugins folder or not
- Calling a function defined by a regular plugin from inside a muplugins_loaded callback — regular plugins have not loaded yet, that causes a fatal error
Related hooks
FAQ
Does muplugins_loaded fire if I have no mu-plugins at all?
Yes — WordPress calls this hook unconditionally on every request, whether the mu-plugins folder has files in it or not.
Can I use functions from my regular plugins inside a muplugins_loaded callback?
No — regular (non-mu) plugins have not loaded yet at this point. That is exactly what plugins_loaded is for.
Source: wp-settings.php