Title: Coding plugin for upgrade
Last modified: August 19, 2016

---

# Coding plugin for upgrade

 *  Resolved [ed4becky](https://wordpress.org/support/users/ed4becky/)
 * (@ed4becky)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/coding-plugin-for-upgrade/)
 * I understand from another thread that 3.1 will no longer call the activation 
   hook when a plugin is upgraded.
 * was wondering if someone could point me to a good example of calling upgrade 
   code outside of the activation, so it is called the minimal number of times.
 * My plugin has an internal version number I can use to check against, I’m just
   not sure of the best place to put the check against the version number and the
   call to the upgrade function

Viewing 1 replies (of 1 total)

 *  Thread Starter [ed4becky](https://wordpress.org/support/users/ed4becky/)
 * (@ed4becky)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/coding-plugin-for-upgrade/#post-1880881)
 * I ended up putting the check in the admin_init hook.
 *     ```
       function rootsPersonaUpgrade() {
         $currentVersion = get_option('rootsPersonaVersion');
         if(!isset($currentVersion) || empty($currentVersion)
       	|| $this->rootsPersonaVersion != $currentVersion) {
       	$installer = new rootsPersonaInstaller();
       	$installer->rootsPersonaUpgrade(ABSPATH . $this->plugin_dir,
       					$this->rootsPersonaVersion);
         }
       }
       ```
   
 * then
 * `add_action( 'admin_init', array($rootsPersonaplugin, 'rootsPersonaUpgrade' ));`

Viewing 1 replies (of 1 total)

The topic ‘Coding plugin for upgrade’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 1 participant
 * Last reply from: [ed4becky](https://wordpress.org/support/users/ed4becky/)
 * Last activity: [15 years, 4 months ago](https://wordpress.org/support/topic/coding-plugin-for-upgrade/#post-1880881)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
