Title: upgrader_pre_install
Published: April 25, 2014
Last modified: February 24, 2026

---

# apply_filters( ‘upgrader_pre_install’, bool|WP_Error $response, array $hook_extra )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/upgrader_pre_install/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/hooks/upgrader_pre_install/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/upgrader_pre_install/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/upgrader_pre_install/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/upgrader_pre_install/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/upgrader_pre_install/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/upgrader_pre_install/?output_format=md#wp--skip-link--target)

Filters the installation response before the installation has started.

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/upgrader_pre_install/?output_format=md#description)󠁿

Returning a value that could be evaluated as a `WP_Error` will effectively short-
circuit the installation, returning that value instead.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/upgrader_pre_install/?output_format=md#parameters)󠁿

 `$response`bool|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)

Installation response.

`$hook_extra`array

Extra arguments passed to hooked filters.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/upgrader_pre_install/?output_format=md#source)󠁿

    ```php
    $res = apply_filters( 'upgrader_pre_install', true, $args['hook_extra'] );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/class-wp-upgrader.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/class-wp-upgrader.php#L555)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/class-wp-upgrader.php#L555-L555)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/upgrader_pre_install/?output_format=md#related)󠁿

| Used by | Description | 
| [WP_Upgrader::install_package()](https://developer.wordpress.org/reference/classes/wp_upgrader/install_package/)`wp-admin/includes/class-wp-upgrader.php` |

Install a package.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/upgrader_pre_install/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.8.0](https://developer.wordpress.org/reference/since/2.8.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/upgrader_pre_install/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/hooks/upgrader_pre_install/?output_format=md#comment-content-7026)
 2.   [Nazmul Ahsan](https://profiles.wordpress.org/mukto90/)  [  2 years ago  ](https://developer.wordpress.org/reference/hooks/upgrader_pre_install/#comment-7026)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupgrader_pre_install%2F%23comment-7026)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupgrader_pre_install%2F%23comment-7026)
 4. If you want to keep the current version and the previous version in the database(
    for debugging purposes)-
 5.     ```php
        <?php
        function wpdocs_plugin_store_previous_version( $upgrader_object, $options ) {
        	if ( 'update' === $options['action'] && 'plugin' === $options['type'] ) {
        		foreach ( $options['plugins'] as $plugin ) {
        			if ( plugin_basename( $plugin ) === 'wpdocs-plugin/wpdocs-plugin.php' ) {
        				update_option( 'wpdocs-plugin_previous_version', WPDOCS_PLUGIN_VER );
        			}
        		}
        	}
        }
    
        function wpdocs_plugin_store_new_version( $upgrader_object, $options ) {
        	if ( 'update' === $options['action'] && 'plugin' === $options['type'] ) {
        		foreach ( $options['plugins'] as $plugin ) {
        			if ( plugin_basename( $plugin ) === 'wpdocs-plugin/wpdocs-plugin.php' ) {
        				update_option( 'wpdocs-plugin_previous_version', get_option( 'wpdocs-plugin_previous_version' ) );
        				update_option( 'wpdocs-plugin_current_version', WPDOCS_PLUGIN_VER );
        			}
        		}
        	}
        }
    
        add_action( 'upgrader_pre_install', 'wpdocs_plugin_store_previous_version', 10, 2 );
        add_action( 'upgrader_process_complete', 'wpdocs_plugin_store_new_version', 10, 2 );
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupgrader_pre_install%2F%3Freplytocom%3D7026%23feedback-editor-7026)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fupgrader_pre_install%2F)
before being able to contribute a note or feedback.