How would I go about overriding an option using the pre_option_ filter before a plugin loads? I am trying to do something like the below, but I can't do it in the wp_config file, because the add_filter function has not loaded yet, and I can't do it in the functions.php file in my theme because the plugin has already loaded at that point.
if (STAGE == 'local') {
function rlrsssl_options() {
return array();
}
add_filter('pre_option_rlrsssl_options', 'rlrsssl_options');
}
How would I go about overriding an option using the pre_option_ filter before a plugin loads? I am trying to do something like the below, but I can't do it in the wp_config file, because the add_filter function has not loaded yet, and I can't do it in the functions.php file in my theme because the plugin has already loaded at that point.
if (STAGE == 'local') {
function rlrsssl_options() {
return array();
}
add_filter('pre_option_rlrsssl_options', 'rlrsssl_options');
}
Share
Improve this question
asked Feb 5, 2021 at 18:08
tkloddtklodd
1296 bronze badges
1 Answer
Reset to default 1If you have code that must run before plugins are loaded, place it in a Must Use Plugin. This is just a PHP file placed in wp-content/mu-plugins/
. Be aware that Must Use Plugins are activated just by existing.