The default_site_option_{$option} WordPress PHP filter allows you to modify the value of a specific default network option.
Usage
add_filter('default_site_option_your_option_name', 'your_custom_function', 10, 3); function your_custom_function($default_value, $option, $network_id) { // your custom code here return $default_value; }
Parameters
$default_value
(mixed): The value to return if the site option does not exist in the database.$option
(string): Option name.$network_id
(int): ID of the network.
More information
See WordPress Developer Resources: default_site_option_{$option}
Examples
Modify the default network option for new site registration
Update the default value for ‘registration’ network option.
add_filter('default_site_option_registration', 'modify_default_registration', 10, 3); function modify_default_registration($default_value, $option, $network_id) { // Set the default registration option to 'user' $default_value = 'user'; return $default_value; }
Change default upload file types
Update the default allowed file types for uploads on new network sites.
add_filter('default_site_option_upload_filetypes', 'modify_default_upload_filetypes', 10, 3); function modify_default_upload_filetypes($default_value, $option, $network_id) { // Set the default allowed file types $default_value = 'jpg, jpeg, png, gif, pdf'; return $default_value; }
Set default maximum upload file size
Change the default maximum upload file size for new network sites.
add_filter('default_site_option_fileupload_maxk', 'modify_default_upload_max_size', 10, 3); function modify_default_upload_max_size($default_value, $option, $network_id) { // Set the default maximum upload file size to 10 MB $default_value = 10240; return $default_value; }
Change default site theme
Set the default theme for new network sites.
add_filter('default_site_option_default_theme', 'modify_default_site_theme', 10, 3); function modify_default_site_theme($default_value, $option, $network_id) { // Set the default theme to 'twentynineteen' $default_value = 'twentynineteen'; return $default_value; }
Modify default post by email settings
Update the default settings for creating a post via email.
add_filter('default_site_option_mailserver_url', 'modify_default_mailserver_url', 10, 3); function modify_default_mailserver_url($default_value, $option, $network_id) { // Set the default mail server URL $default_value = 'imap.example.com'; return $default_value; }