The network_sites_updated_message_{$_GET[‘updated’]} WordPress PHP action allows you to filter and customize non-default site update messages in the Network admin.
Usage
add_filter('network_sites_updated_message_custom_action', 'your_custom_function_name', 10, 1);
function your_custom_function_name($msg) {
// your custom code here
return $msg;
}
Parameters
$msg (string): The update message. Default is ‘Settings saved’.
More information
See WordPress Developer Resources: network_sites_updated_message_{$_GET[‘updated’]}
Examples
Customizing the Update Message for a Specific Action
Customize the update message when a specific action, e.g. ‘my_custom_action’, has been performed.
add_filter('network_sites_updated_message_my_custom_action', 'customize_my_custom_action_message', 10, 1);
function customize_my_custom_action_message($msg) {
$msg = 'My custom action completed successfully.';
return $msg;
}
Adding Additional Information to the Update Message
Add extra information to the default update message.
add_filter('network_sites_updated_message_updated', 'add_additional_info_to_update_message', 10, 1);
function add_additional_info_to_update_message($msg) {
$msg .= ' Please check your email for further details.';
return $msg;
}
Displaying an Error Message
Display an error message when a specific action, e.g. ‘failed_action’, has failed.
add_filter('network_sites_updated_message_failed_action', 'display_failed_action_message', 10, 1);
function display_failed_action_message($msg) {
$msg = 'Error: The action failed. Please try again later.';
return $msg;
}
Customizing Update Message Based on a Condition
Customize the update message for a specific action, e.g. ‘conditional_action’, based on a certain condition.
add_filter('network_sites_updated_message_conditional_action', 'customize_conditional_action_message', 10, 1);
function customize_conditional_action_message($msg) {
if (current_user_can('manage_options')) {
$msg = 'Action completed. You have the required permissions.';
} else {
$msg = 'Action completed. You do not have the required permissions.';
}
return $msg;
}
Translating the Update Message
Translate the update message for a specific action, e.g. ‘translated_action’, using gettext functions.
add_filter('network_sites_updated_message_translated_action', 'translate_action_message', 10, 1);
function translate_action_message($msg) {
$msg = __('Action completed. Settings saved.', 'text-domain');
return $msg;
}