0

My plugin only installs correctly if the user first deactivates and then deletes a previously installed version. If they do not delete the previous version, the installation either does not complete or the plugin, once installed, does not work.

Although it would be nice to get at the heart of why this is occurring, it seems like for best user experience anyway the plugin should automatically deactivate and remove previous versions upon installation. Is this possible?

1

Quick and easy.

if ( is_plugin_active( 'plugin-folder-name/main-plugin-file.php' ) )
    deactivate_plugins( '/plugin-folder-name/main-plugin-file.php' );

It's important to note the is_plugin_active string is slightly different than the deactivate_plugins string.

  • Thanks, Matthew! This deactivates the plugin... would I then want to uninstall_plugins( '/plugin-folder-name/main-plugin-file.php' ); ? – josh Mar 9 '12 at 18:10

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.