0

As per the title. I have a new version of a plugin. It installs fine on a clean WordPress. When a user tries to install it when they have a previous version installed, the plugin does not function. It does not matter if the previous version was active or not. Ideally, I would like to ensure that the new version uninstalls the previous version before writing any files itself. Is this possible?

Alternatively, if anybody has any idea why we are encountering this issue, I would not be opposed to just fixing it. :)

  • Did you write the plugins 1 + 2? – kaiser Apr 24 '12 at 23:22
  • the plugin does not function – enable the debug mode and see why the second plugin doesn't work. – fuxia Apr 25 '12 at 6:09
  • @kaiser I did not - how did you guess? :) If I had written it I would hope I might at least have some idea what was going on with it. As it stands I can only try desperately to parse and debug the poorly written and thoroughly undocumented code. – josh Apr 25 '12 at 17:17
  • @toscho unfortunately, it only doesn't work for some clients under certain circumstances... we are not able to reproduce their issues, but they have cropped up often enough to convince us that it's not user error, and they are resolved by properly uninstalling the old version first. – josh Apr 25 '12 at 17:18
2

On the register_activation_hook() function of the new plugin use the function deactivate_plugins() (or deactivate_plugin_before_upgrade()) and deactivate the older plugin and also delete the data with delete_option. If you will also delete the files, then use the function uninstall_plugin($plugin); maybe delete_plugins( $plugins, $redirect = '' )

  • This looks promising, I'll give it a shot, thanks! – josh Apr 25 '12 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.