The myblogs_options WordPress PHP filter enables the Global Settings section on the My Sites screen, which is hidden by default.
Usage
add_filter('myblogs_options', 'your_custom_function', 10, 2);
function your_custom_function($settings_html, $context) {
// your custom code here
return $settings_html;
}
Parameters
- $settings_html (string) – The settings HTML markup. Default empty.
- $context (string) – Context of the setting (global or site-specific). Default ‘global’.
More information
See WordPress Developer Resources: myblogs_options
Examples
Enabling the Global Settings section
This example enables the Global Settings section on the My Sites screen:
add_filter('myblogs_options', 'enable_global_settings_section', 10, 2);
function enable_global_settings_section($settings_html, $context) {
if ($context === 'global') {
return 'Enabled';
}
return $settings_html;
}
Adding a custom setting to the Global Settings section
This example adds a custom setting to the Global Settings section:
add_filter('myblogs_options', 'add_custom_global_setting', 10, 2);
function add_custom_global_setting($settings_html, $context) {
if ($context === 'global') {
$custom_setting = '<p>Custom global setting goes here.</p>';
return $settings_html . $custom_setting;
}
return $settings_html;
}
Adding a site-specific setting
This example adds a custom site-specific setting to the My Sites screen:
add_filter('myblogs_options', 'add_site_specific_setting', 10, 2);
function add_site_specific_setting($settings_html, $context) {
if ($context === 'site-specific') {
$custom_setting = '<p>Site-specific setting goes here.</p>';
return $settings_html . $custom_setting;
}
return $settings_html;
}
Modifying an existing setting in the Global Settings section
This example modifies an existing setting in the Global Settings section:
add_filter('myblogs_options', 'modify_existing_global_setting', 10, 2);
function modify_existing_global_setting($settings_html, $context) {
if ($context === 'global') {
// Modify the existing setting HTML here
$settings_html = str_replace('old_setting', 'new_setting', $settings_html);
}
return $settings_html;
}
Removing a setting from the Global Settings section
This example removes a specific setting from the Global Settings section:
add_filter('myblogs_options', 'remove_setting_from_global_section', 10, 2);
function remove_setting_from_global_section($settings_html, $context) {
if ($context === 'global') {
// Remove the specific setting HTML here
$settings_html = str_replace('<p>Specific setting to remove</p>', '', $settings_html);
}
return $settings_html;
}