The after_mu_upgrade WordPress PHP filter is used to trigger actions after the Multisite database upgrade for each site is completed.
Usage
add_filter('after_mu_upgrade', 'my_custom_function', 10, 1); function my_custom_function($response) { // your custom code here return $response; }
Parameters
$response
(array): The upgrade response array.
More information
See WordPress Developer Resources: after_mu_upgrade
Examples
Log upgrade completion
Log the completion of the Multisite database upgrade for each site.
add_filter('after_mu_upgrade', 'log_upgrade_completion', 10, 1); function log_upgrade_completion($response) { error_log("Multisite upgrade completed for site: " . $response['blog_id']); return $response; }
Send email notification
Send an email notification after the Multisite database upgrade for each site.
add_filter('after_mu_upgrade', 'send_upgrade_notification', 10, 1); function send_upgrade_notification($response) { $admin_email = get_option('admin_email'); wp_mail($admin_email, 'Multisite Upgrade Completed', 'The upgrade for site ' . $response['blog_id'] . ' has been completed.'); return $response; }
Update site option
Update a site option after the Multisite database upgrade for each site.
add_filter('after_mu_upgrade', 'update_site_option_after_upgrade', 10, 1); function update_site_option_after_upgrade($response) { update_option('my_custom_option', 'Upgrade Completed'); return $response; }
Run custom database queries
Run custom database queries after the Multisite database upgrade for each site.
add_filter('after_mu_upgrade', 'run_custom_queries', 10, 1); function run_custom_queries($response) { global $wpdb; $wpdb->query("YOUR_CUSTOM_SQL_QUERY_HERE"); return $response; }
Perform maintenance tasks
Perform maintenance tasks after the Multisite database upgrade for each site.
add_filter('after_mu_upgrade', 'perform_maintenance_tasks', 10, 1); function perform_maintenance_tasks($response) { // Clean up temporary files // Optimize database tables // etc. return $response; }