The core_upgrade_preamble WordPress PHP action fires after the core, plugin, and theme update tables.
Usage
add_action('core_upgrade_preamble', 'your_custom_function'); function your_custom_function() { // your custom code here }
Parameters
- None
More information
See WordPress Developer Resources: core_upgrade_preamble
Examples
Display a custom message after the update tables
Add a custom message after the update tables to inform users about any additional steps or information.
add_action('core_upgrade_preamble', 'custom_message_after_update_tables'); function custom_message_after_update_tables() { echo '**Please remember to clear your browser cache after updating.**'; }
Log update events
Log update events for auditing purposes.
add_action('core_upgrade_preamble', 'log_update_events'); function log_update_events() { // Log the date and time of the update error_log('Update tables process started on ' . date("Y-m-d H:i:s")); }
Send an email notification after updates
Send an email notification to the administrator after updates.
add_action('core_upgrade_preamble', 'send_email_after_updates'); function send_email_after_updates() { $to = '[email protected]'; $subject = 'WordPress Updates Completed'; $message = 'The updates for core, plugins, and themes have been completed.'; wp_mail($to, $subject, $message); }
Deactivate plugins before updates
Deactivate specific plugins before the update process.
add_action('core_upgrade_preamble', 'deactivate_plugins_before_updates'); function deactivate_plugins_before_updates() { $plugins_to_deactivate = array( 'plugin-1/plugin-1.php', 'plugin-2/plugin-2.php' ); deactivate_plugins($plugins_to_deactivate); }
Backup site before updates
Trigger a site backup before performing updates.
add_action('core_upgrade_preamble', 'backup_site_before_updates'); function backup_site_before_updates() { // Use a backup function or plugin to create a backup your_backup_function(); }