do_action( 'automatic_updates_complete', array $update_results )

Fires after all automatic updates have run.


Parameters Parameters

$update_results

(array) The results of all attempted updates.


Top ↑

Source Source

File: wp-admin/includes/class-wp-automatic-updater.php

View on Trac



Top ↑

Changelog Changelog

Changelog
Version Description
3.8.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by MattDotNet

    This hook is pretty useful in case you need to perform some stuff after an automatic update gets completed by WordPress. I personally spent a lot of time figuring out how to deal with this feature, especially because I didn’t know what kind of data the $update_results parameter contained.

    So, here’s a working example of how you should use this hook.

    /**
     * Fires after all automatic updates have run.
     * Completes the update scheduled in background.
     *
     * @param  array  $results  The results of all attempted updates.
     *
     * @since  3.8.0
     */
    add_action( 'automatic_updates_complete', 'wpdocs_auto_update_complete' );
    
    function wpdocs_auto_update_complete( $results ) {
    	// the list of plugins is contained within the "plugins" attribute
    	foreach ( $results['plugin'] as $plugin ) {
    		// make sure the plugin slug matches the one assigned to your own plugin
    		if ( ! empty( $plugin->item->slug ) && '{plugin_slug}' === $plugin->item->slug ) {
    			/**
    			 * @todo Plugin found! Do stuff here...
    			 */
    		}
    	}
    }
    

You must log in before being able to contribute a note or feedback.