Using WordPress ‘do_undismiss_core_update()’ PHP function

The do_undismiss_core_update() WordPress PHP function is used to undismiss a previously dismissed core update.

Usage

Let’s assume you have previously dismissed a core update and want to undo that action. Here’s a simple way to do it:

do_undismiss_core_update();

This function doesn’t require any parameters, it will simply undo the last dismissed update.

Parameters

This function doesn’t have any parameters.

More information

See WordPress Developer Resources: do_undismiss_core_update()

This function is included in WordPress from version 3.7.0 onwards.

Examples

Undo a dismissed update

This will undismiss the last dismissed core update:

do_undismiss_core_update(); // Undoes the last dismissed update

Check if an update is available, and if so, undismiss it

This example checks if an update is available. If an update is available, and it has been dismissed, it undismisses it.

if ( function_exists( 'get_core_updates' ) ) {
    $updates = get_core_updates();
    if ( ! empty( $updates ) ) {
        do_undismiss_core_update(); // Undismiss the update if it exists
    }
}

Undismiss an update before checking for updates again

This example undismisses an update, then forces WordPress to check for updates again.

do_undismiss_core_update(); // First, undismiss the update

if ( function_exists( 'wp_version_check' ) ) {
    wp_version_check(); // Then, check for updates again
}

Undismiss an update and redirect to the updates page

This example undismisses an update, then redirects the user to the WordPress updates page.

do_undismiss_core_update(); // Undismiss the update

wp_redirect( admin_url( 'update-core.php' ) ); // Then, redirect to the updates page
exit;

Schedule a task to undismiss an update

This example uses the WordPress cron functionality to schedule a task that will undismiss an update at a specific time.

if ( ! wp_next_scheduled( 'undismiss_core_update' ) ) {
    wp_schedule_single_event( time() + 3600, 'undismiss_core_update' ); // Schedule the undismiss task for 1 hour from now
}

add_action( 'undismiss_core_update', 'do_undismiss_core_update' ); // Undismiss the update when the scheduled task runs

In this case, the do_undismiss_core_update function will be called 1 hour from now, undismissing the last dismissed core update.