The make_undelete_blog WordPress PHP action fires when the ‘deleted’ status is removed from a site.
Usage
add_action('make_undelete_blog', 'your_custom_function', 10, 1); function your_custom_function($site_id) { // your custom code here }
Parameters
$site_id
(int) – Site ID.
More information
See WordPress Developer Resources: make_undelete_blog
Examples
Log undelete event
Log the undelete event for a site.
add_action('make_undelete_blog', 'log_undelete_event', 10, 1); function log_undelete_event($site_id) { error_log("Site {$site_id} has been undeleted."); }
Send email notification
Send an email notification to the admin when a site is undeleted.
add_action('make_undelete_blog', 'send_undelete_notification', 10, 1); function send_undelete_notification($site_id) { $admin_email = get_site_option($site_id, 'admin_email'); wp_mail($admin_email, 'Your site has been undeleted', 'Your site is now active again.'); }
Update custom field
Update a custom field in the site’s options when the site is undeleted.
add_action('make_undelete_blog', 'update_custom_field', 10, 1); function update_custom_field($site_id) { update_blog_option($site_id, 'undelete_timestamp', time()); }
Add undelete log
Add an undelete log entry to a custom log table in the database.
add_action('make_undelete_blog', 'add_undelete_log', 10, 1); function add_undelete_log($site_id) { global $wpdb; $wpdb->insert($wpdb->prefix . 'undelete_log', array('site_id' => $site_id, 'timestamp' => current_time('mysql'))); }
Trigger custom event
Trigger a custom event when a site is undeleted.
add_action('make_undelete_blog', 'trigger_custom_event', 10, 1); function trigger_custom_event($site_id) { do_action('my_custom_undelete_event', $site_id); }