Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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. :)

share|improve this question
    
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. –  toscho 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
add comment

1 Answer

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 = '' )

share|improve this answer
    
This looks promising, I'll give it a shot, thanks! –  josh Apr 25 '12 at 17:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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