wp_set_option_autoload()
Changes an option's autoload setting when WordPress starts without changing its value.
A wrapper for wp_set_option_autoload_values() that changes the autoload setting of one option.
No Hooks.
Returns
true|false.
true- the autoload setting changed.false- the setting did not change, the option does not exist, or an error occurred.
Usage
wp_set_option_autoload( $option, $autoload );
- $option(string) (required)
- Option name without SQL escaping.
- $autoload(bool) (required)
- Enables (
true) or disables (false) autoloading. The'yes'and'no'values are supported for backwards compatibility but deprecated.
Examples
#1 Disable option auto-load
wp_set_option_autoload( 'my_plugin_report_data', false );
Notes
Changelog
| Since 6.4.0 | Introduced. |
| Since 6.7.0 | The autoload values 'yes' and 'no' are deprecated. |
wp_set_option_autoload() wp set option autoload code WP 7.0.4
function wp_set_option_autoload( $option, $autoload ) {
$result = wp_set_option_autoload_values( array( $option => $autoload ) );
return $result[ $option ] ?? false;
}