Title: Plugin activation hooks no longer fire for updates
Author: Andrew Nacin
Published: October 27, 2010
Last modified: July 10, 2015

---

 [  ](https://profiles.wordpress.org/nacin/) [Andrew Nacin](https://profiles.wordpress.org/nacin/)
10:16 pm _on_ October 27, 2010     
Tags: [3.1 ( 12 )](https://make.wordpress.org/core/tag/3-1/),
[dev-notes ( 661 )](https://make.wordpress.org/core/tag/dev-notes/)   

# Plugin activation hooks no longer fire for updates

Following up on [@scribu](https://profiles.wordpress.org/scribu/)‘s [post](http://wpdevel.wordpress.com/2010/10/27/plugin-activation-hooks/)
with further rationale and the 31compat tagtag A directory in Subversion. WordPress
uses tags to store a single snapshot of a version (3.6, 3.6.1, etc.), the common
convention of tags in version control systems. (Not to be confused with post tags.).

**The many problems.** When pluginPlugin A plugin is a piece of software containing
a group of functions that can be added to a WordPress website. They can extend functionality
or add new features to your WordPress websites. WordPress plugins are written in
the PHP programming language and integrate seamlessly with WordPress. These can 
be free in the WordPress.org Plugin Directory [https://wordpress.org/plugins/](https://wordpress.org/plugins/)
or can be cost-based plugin from a third-party. upgrades were introduced in 2.8,
the activation hook fired for them. The deactivation hook did not. This was inconsistency
number one.

When bulk plugin upgrades were introduced on the Tools > Updates screen in 2.9, 
the activation hook did not fire (during the bulk upgrade). This was inconsistency
number two.

Bulk plugin upgrades were given greater prominence in 3.0, with the Updates move
to under Dashboard, and a new bulk action on the plugins screen. This made the second
inconsistency far more prominent.

Additionally, activation hooksHooks In WordPress theme and development, hooks are
functions that can be applied to an action or a Filter in WordPress. Actions are
functions performed when a certain event occurs in WordPress. Filters allow you 
to modify certain functions. Arguments used to hook both filters and actions look
the same. could always fire on activation, because that has to be done through the
adminadmin (and super admin), but updates don’t. Updates done manually (including
SVNSVN Subversion, the popular version control system (VCS) by the Apache project,
used by WordPress to manage changes to its codebase.) was just one more instance
where we may not have been firing updates. This was inconsistency number three.

We felt that the proper fix was to prevent the activation hook from firing on any
upgrades, bulk or not, as this was not intuitive. Sorry if your plugin relied on
this undocumented behavior.

**The theory behind the right way to do this.** The proper way to handle an upgrade
path is to only run an upgrade procedure when you need to. Ideally, you would store
a “version” in your plugin’s database option, and then a version in the code. If
they do not match, you would fire your upgrade procedure, and then set the database
option to equal the version in the code. This is how many plugins handle upgrades,
and this is how coreCore Core is the set of software required to run WordPress. 
The Core Development Team builds WordPress. works as well.

**The right way to do this.** I would do what [many](https://wordpress.org/extend/plugins/log-deprecated-notices/)
[other](https://wordpress.org/extend/plugins/simple-footnotes/) plugins do and do
the upgrade procedure as I described, and [as Peter and Andy described in the previous post](http://wpdevel.wordpress.com/2010/10/27/plugin-activation-hooks/#comment-11989).

**Further reading.** You can read more about this issue, on ticketticket Created
for both bug reports and feature development on the bug tracker. [#14915](https://core.trac.wordpress.org/ticket/14915).

[#3-1](https://make.wordpress.org/core/tag/3-1/), [#dev-notes](https://make.wordpress.org/core/tag/dev-notes/)

### Share this:

 * [  Threads ](https://make.wordpress.org/core/2010/10/27/plugin-activation-hooks-no-longer-fire-for-updates/?share=threads)
 * [  Mastodon ](https://make.wordpress.org/core/2010/10/27/plugin-activation-hooks-no-longer-fire-for-updates/?share=mastodon)
 * [  Bluesky ](https://make.wordpress.org/core/2010/10/27/plugin-activation-hooks-no-longer-fire-for-updates/?share=bluesky)
 * [  X ](https://make.wordpress.org/core/2010/10/27/plugin-activation-hooks-no-longer-fire-for-updates/?share=x)
 * [  Facebook ](https://make.wordpress.org/core/2010/10/27/plugin-activation-hooks-no-longer-fire-for-updates/?share=facebook)
 * [  LinkedIn ](https://make.wordpress.org/core/2010/10/27/plugin-activation-hooks-no-longer-fire-for-updates/?share=linkedin)

 1.  ![](https://secure.gravatar.com/avatar/ff53a1a6524d6a7265fe8d9d4ed5bb47fcf2156eb8395df81f2be0f7bd82bf02?
     s=32&d=mm&r=g)
 2.   Michael Torbert  10:18 pm _on_ October 27, 2010
 3.  Even though that’s certainly a way to accomplish the same thing, the logical solution
     would be to make another hook for activation.
 4.   * ![](https://secure.gravatar.com/avatar/756c2e0e82712f382e451c45008d32f73ebb14f01c1d8447bd44b7dcf67e61dd?
        s=32&d=mm&r=g)
      *  [Ryan Boren](http://ryan.boren.me/)  10:20 pm _on_ October 27, 2010
      * Which would not run for manually upgraded plugins. HooksHooks In WordPress 
        theme and development, hooks are functions that can be applied to an action
        or a Filter in WordPress. Actions are functions performed when a certain event
        occurs in WordPress. Filters allow you to modify certain functions. Arguments
        used to hook both filters and actions look the same. for upgrades is a non-
        starter. Plugins have to do it.
         - ![](https://secure.gravatar.com/avatar/ff53a1a6524d6a7265fe8d9d4ed5bb47fcf2156eb8395df81f2be0f7bd82bf02?
           s=32&d=mm&r=g)
         -  Michael Torbert  10:25 pm _on_ October 27, 2010
         - I would guess that most plugins are automatically upgraded, making this 
           a simple solution.
         - ![](https://secure.gravatar.com/avatar/756c2e0e82712f382e451c45008d32f73ebb14f01c1d8447bd44b7dcf67e61dd?
           s=32&d=mm&r=g)
         -  [Ryan Boren](http://ryan.boren.me/)  10:29 pm _on_ October 27, 2010
         - Many people use git or svn, and relying on a hook is not multisitemultisite
           Used to describe a WordPress installation with a network of multiple blogs,
           grouped by sites. This installation type has shared users tables, and creates
           separate database tables for each blog (wp_posts becomes wp_0_posts). See
           also **network**, **blog**, **site** compatible.
 5.  ![](https://secure.gravatar.com/avatar/3c2d35c70cfeb674f1fddcff8fdc6010f63d833d4ead58bba947d7578f039bd3?
     s=32&d=mm&r=g)
 6.   [Stephen Cronin](http://www.scratch99.com/)  1:55 pm _on_ October 28, 2010
 7.  Thanks for explaining that Nacin.
 8.  I’m currently misusing the activation hook – my activation function includes all
     the update logic I need. I’m aware it doesn’t work for FTPFTP FTP is an acronym
     for File Transfer Protocol which is a way of moving computer files from one computer
     to another via the Internet. You can use software, known as a FTP client, to upload
     files to a server for a WordPress website. [https://codex.wordpress.org/FTP_Clients](https://codex.wordpress.org/FTP_Clients)
     updates, so my update instructions tell people to deactivate and then reactivate
     the pluginPlugin A plugin is a piece of software containing a group of functions
     that can be added to a WordPress website. They can extend functionality or add
     new features to your WordPress websites. WordPress plugins are written in the 
     PHP programming language and integrate seamlessly with WordPress. These can be
     free in the WordPress.org Plugin Directory [https://wordpress.org/plugins/](https://wordpress.org/plugins/)
     or can be cost-based plugin from a third-party.. Of course, that won’t work for
     SVNSVN Subversion, the popular version control system (VCS) by the Apache project,
     used by WordPress to manage changes to its codebase. updates, which I hadn’t considered(
     although with due respect to Ryan, I’d argue that not many *average users* would
     update via SVN).
 9.  If the logic needs to be handled via the plugins, that’s fine, I’ll update mine.
     In fac,t I used to handle it in the plugin but removed it because I figured that
     running something just on activation would be more efficient that checking the
     version number on every single page load. For one plugin, not much of a drama,
     but when you start having 30 plugins all checking their version number on every
     page load of the site… But if that’s what we have to do, then that’s what we have
     to do.
 10.  * ![](https://secure.gravatar.com/avatar/e1b554bd816eeeca8e01b08ab27215d529cce71f0d8bb246bb9f6b1cb9d400a9?
        s=32&d=mm&r=g)
      *  [Andy Skelton](http://skeltoac.com/)  2:16 pm _on_ October 28, 2010
      * It’s not inefficient for every pluginPlugin A plugin is a piece of software
        containing a group of functions that can be added to a WordPress website. They
        can extend functionality or add new features to your WordPress websites. WordPress
        plugins are written in the PHP programming language and integrate seamlessly
        with WordPress. These can be free in the WordPress.org Plugin Directory [https://wordpress.org/plugins/](https://wordpress.org/plugins/)
        or can be cost-based plugin from a third-party. to store a small amount of 
        data in the options table. They will all be automatically loaded with a single
        query. The overhead added by a single, small row is small enough to ignore.
         - ![](https://secure.gravatar.com/avatar/34368b9c92a4bfa3bd2a84a222147375526d5ccfbbb3afe32abfbd1bc37f5b58?
           s=32&d=mm&r=g)
         -  [Peter Westwood](http://westi.wordpress.com/)  2:19 pm _on_ October 28,
           2010
         - Agreed.
            Also – you should try really hard to ensure your pluginPlugin A
           plugin is a piece of software containing a group of functions that can be
           added to a WordPress website. They can extend functionality or add new features
           to your WordPress websites. WordPress plugins are written in the PHP programming
           language and integrate seamlessly with WordPress. These can be free in the
           WordPress.org Plugin Directory [https://wordpress.org/plugins/](https://wordpress.org/plugins/)
           or can be cost-based plugin from a third-party. still works even with the
           old settings until the upgrade had happened unless it can be done without
           user interaction. In most cases if you need user interaction you can trigger
           an admin_notice on the next page load after the update. If you have a update
           that takes a while consider using a wp-cron “job” to do the migrationMigration
           Moving the code, database and media files for a website site from one server
           to another. Most typically done when changing hosting companies. work.
         - ![](https://secure.gravatar.com/avatar/3c2d35c70cfeb674f1fddcff8fdc6010f63d833d4ead58bba947d7578f039bd3?
           s=32&d=mm&r=g)
         -  [Stephen Cronin](http://www.scratch99.com/)  2:47 pm _on_ October 28, 2010
         - Thanks for pointing that Andy.
         - I was assuming a separate DB call for each pluginPlugin A plugin is a piece
           of software containing a group of functions that can be added to a WordPress
           website. They can extend functionality or add new features to your WordPress
           websites. WordPress plugins are written in the PHP programming language 
           and integrate seamlessly with WordPress. These can be free in the WordPress.
           org Plugin Directory [https://wordpress.org/plugins/](https://wordpress.org/plugins/)
           or can be cost-based plugin from a third-party.’s options entry. I knew 
           the coreCore Core is the set of software required to run WordPress. The 
           Core Development Team builds WordPress. options were bundled into a single
           DB call, but was under the impression (from heresay, not anything resembling
           facts) that non core options weren’t included and needed a separate DB call.
         - And Peter, yes, you’re right of course, the plugin shouldn’t rely on something
           existing that may not be there. I code properly *most* of the time, but 
           I guess I’ve leant on the activation hook crutch occasionally. I think I
           need to spend some time with my plugins and make sure I’m not making the
           problem I’m complaining about 🙂
         - ![](https://secure.gravatar.com/avatar/34368b9c92a4bfa3bd2a84a222147375526d5ccfbbb3afe32abfbd1bc37f5b58?
           s=32&d=mm&r=g)
         -  [Peter Westwood](http://westi.wordpress.com/)  2:49 pm _on_ October 28,
           2010
         - @Stephen: As long as you ask for your option to be autoloaded when registered
           it comes in one query with the rest of the autoloads
         - ![](https://secure.gravatar.com/avatar/fdfe9ec238a74313ed7c31abf2989c1c735342a3084ee311eb2fa4c1fe54fd55?
           s=32&d=mm&r=g)
         -  [demetris](http://op111.net/)  11:48 am _on_ October 29, 2010
         - Just a note regarding autoloading of options:
         - By default, autoload is set to yes for all options added via add_option.
           So, other than adding your option, there is nothing you need to specify 
           if you want it to be autoloaded.
         - More here: [https://codex.wordpress.org/Function_Reference/add_option](https://codex.wordpress.org/Function_Reference/add_option)
 11. ![](https://secure.gravatar.com/avatar/142bfc70dfa916d7bb62311116b5ad35251dfe7d5faa153c243071867190312e?
     s=32&d=mm&r=g)
 12.  [Jarkko Laine](http://jarkkolaine.com)  7:35 pm _on_ April 12, 2011
 13. Hi, just a quick note to point out that this documentation page is still giving
     wrong instructions for pluginPlugin A plugin is a piece of software containing
     a group of functions that can be added to a WordPress website. They can extend
     functionality or add new features to your WordPress websites. WordPress plugins
     are written in the PHP programming language and integrate seamlessly with WordPress.
     These can be free in the WordPress.org Plugin Directory [https://wordpress.org/plugins/](https://wordpress.org/plugins/)
     or can be cost-based plugin from a third-party. developers: [https://codex.wordpress.org/Creating_Tables_with_Plugins](https://codex.wordpress.org/Creating_Tables_with_Plugins)
 14. Cheers,
      Jarkko
 15. ![](https://secure.gravatar.com/avatar/fecf074ac5de419fc64793a29ee4f6b764caa39631550e7ebf12fe66c1bcadfd?
     s=32&d=mm&r=g)
 16.  [Clint](http://clintberry.com)  2:54 am _on_ May 15, 2012
 17. I am VERY late to this party, but when I manually de-activate a pluginPlugin A
     plugin is a piece of software containing a group of functions that can be added
     to a WordPress website. They can extend functionality or add new features to your
     WordPress websites. WordPress plugins are written in the PHP programming language
     and integrate seamlessly with WordPress. These can be free in the WordPress.org
     Plugin Directory [https://wordpress.org/plugins/](https://wordpress.org/plugins/)
     or can be cost-based plugin from a third-party., and then reactivate it again 
     manually, won’t fire the “acivation hook”? Seems a little stupid. Also makes testing
     my plugin a huge pain.
 18.  * ![](https://secure.gravatar.com/avatar/1a7df76f4f6519a5618c32428b277a5c7a89798394965b67e50528ca57c1b5a8?
        s=32&d=mm&r=g)
      *  [Andrew Nacin](https://profiles.wordpress.org/nacin/)  8:40 pm _on_ August
        31, 2012
      * Even later to reply to you — If you manually de-activate and manually reactivate,
        _yes_, it fires the activation (and deactivation) hooksHooks In WordPress theme
        and development, hooks are functions that can be applied to an action or a 
        Filter in WordPress. Actions are functions performed when a certain event occurs
        in WordPress. Filters allow you to modify certain functions. Arguments used
        to hook both filters and actions look the same.. This was only for coreCore
        Core is the set of software required to run WordPress. The Core Development
        Team builds WordPress.’s one-click updates — when we update a pluginPlugin 
        A plugin is a piece of software containing a group of functions that can be
        added to a WordPress website. They can extend functionality or add new features
        to your WordPress websites. WordPress plugins are written in the PHP programming
        language and integrate seamlessly with WordPress. These can be free in the 
        WordPress.org Plugin Directory [https://wordpress.org/plugins/](https://wordpress.org/plugins/)
        or can be cost-based plugin from a third-party., we do not fire an activation
        hook.

Comments are closed.

# Post navigation

[← Plugin activation hooks](https://make.wordpress.org/core/2010/10/27/plugin-activation-hooks/)

[Suggest agenda items for tomorrow’s dev… →](https://make.wordpress.org/core/2010/10/27/suggest-agenda-items-for-tomorrows-dev/)