WordPress.org

Ready to get started?Download WordPress

Forums

Plugin: deactivating functions (3 posts)

  1. nutsmuggler
    Member
    Posted 8 years ago #

    Hi. I am buidling a plugin that creates a new table and some options to the wp data base. ThusI need to eliminate the table and aoptions when the plugin is uninstalled.
    Where do I hook in?
    I tried

    if (isset($_GET['deactivate']) && $_GET['deactivate'] == 'true') {
    add_action('init', 'dbes_uninstall');
    }
    to call the dbes_uninstall function.
    Yet this doesn't seem to work...
    Any suggestion?
    Thanks in advance,
    Davide

  2. jalenack
    Member
    Posted 8 years ago #

    Hey. That's because WordPress doesn't get to your code when WP deactivates your plugin. It takes it out of the include cycle as soon as the button is pressed.

    Also, I recommend not having your plugin completely uninstall itself when it is deactivated. There isn't a ton of harm in having idle tables, and users might squawk when their data disappears. I have two plugins that install their own tables, and I never run any uninstall code.

    Cheers

  3. nutsmuggler
    Member
    Posted 8 years ago #

    Ok, i see.
    It was obvious ...
    Anyway, leaving the table would do no harm, but I must get rid of the options somehow, and of a specific page built by the plugin...
    Is there any strategy to perform a php script when uninstalling a plugin?
    Cheers,
    Davide

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.