The Plugin API has hooks for that:
You can use register_deactivation_hook
to run a function when the plugin is deactivated.
For uninstall, you have two options. Either register_uninstall_hook
or add a file called uninstall.php
in your plugin folder.
I would not recommend delete plugin options on plugin deactivation though, the user might not know that he is losing his saved data.
Related Posts:
- Delete tables from database when deleting plugin
- Using Vagrant for customizable WordPress Multi-sites [closed]
- Creating button next to “add media” that allows you to choose a single post
- WooCommerce create new product and add to cart on form submit
- Extending WC_Cart in woocommerce
- WordPress Plugin as ‘Library’ From Abstract Application?
- Custom comment type maybe?
- Add custom meta box on Post page
- Posts wont expire
- Why is this custom taxonomy showing in the database?
- WordPress Plugin development Call to undefined function jQuery()
- Created Widget Not Showing up on Admin Panel
- plugin for wp_list_categories with posts
- I need to add a custom “cover” to every new post — plugin or custom setup?
- How to get last_updated and newest_blogs in WP 3.0
- Replace existing pages with new pages, keep menu links
- Recommendations for books/resource to get started with wordpress 3 development (plugins/themes) [closed]
- Will Flutter work with WordPress 3.0?
- Check if User exists in WordPress Multisite
- Custom plugins/Manipulated plugins: Always a terrible idea to inherit these types of WP sites that discourage updates? [closed]
- wordpress.org codebase
- Can a plugin deactivate and delete itself once installed and activated?
- How to modify shortcode attributes with data from current post
- How to import my YouTube channel into WordPress?
- My Category is too big on the Menu what can i do?
- How to Create a Custom Panel and Fields in Post Page [Plugin]
- Does any one have Idea to get these functionalities with the plugin wp-multi-network
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Send reply with pre-prepared answers
- Best place for short bio,image and button [closed]
- Automatic Updates Individual Plugins Not Working
- How create Group Blogs based on user created Groups
- Custom table naming/access convention for multisite: $table_prefix vs base_prefix or other?
- WordPress as web application base
- URL rewrite of independent plugin?
- Plugin for users to create their own ads like Google Adsence
- How do I apply style to each category of a list?
- Inserting custom PHP script on homepage
- Best practice for including plugin output in a template without using shortcode?
- a weird attribute on every html tag
- How can I run a custom shortcode function on a live site and only run if the viewer is a specific machine?
- Custom widget doesn’t save values from dropdown box
- Plugin function inside custom plugin
- Change the style of h1, h2, only in post entry
- How to change the wp_upload_dir() path in plugin
- Custom API plugin to execute 3rd party API to retrieve data
- Advanced WordPress plugin activation detection
- Customize Menu | Styling LESS/SCSS code formats
- shortcode – multiple instances of same parameter name in one shortcode instance
- How to create a plugin that includes all the other plugins?
- Why is it important to check for isset and is_array before checking in_array in this example?
- how to change wp-admin url using function file
- Calling a save function from a “submit” button
- Is there a way to easily manage Project options (custom-fields)
- How Should Custom Functions Be Called For Single Posts?
- same user role or copy the user role to be same as the other role
- Renaming Custom Taxonomy Values
- Add a “default sorting” menu to child store pages
- Want to modify a Plugin – Tweetily – Can I make it tweet a Custom Field instead of Post Title?
- Integrating Custom Database with WordPress
- Custom Module, Extending WP with a Plugin?
- How can I replace content on site generated from plugin without changing plugin
- Rename Smart YouTube’s httpv back to http for all posts
- Edit post image attributes on fly?
- How to make PDF books readable on site with woo-commerce?
- Replace only the first CSS class
- Ultimate Members Default Post Layout problem
- Why does plugin_url append absolute file path?
- How to send custom mail when a user complete a specific form
- Echo custom admin field into a is_single()
- Manual Backup – How to save to Firefox or Chrome (instead of IE which brings up popup I can’t get rid of)
- How can I save cookies to members
- Overwrite user role
- Am I using an action hook correctly?
- Should I paste CDN links in a JS file or use a Bootstrap CDN plugin?
- Conditional required fields for WordPress Contact Form 7
- Problem with Duplicate Meta / tag description in Webmaster Tool [duplicate]
- Replace code in plugin template
- Restrict my pages from public
- Style WordPress Custom Post Type Single Page
- Display_rows() and column_cb() strange behaviour
- Directory structure for plugin changes
- How can I pass value to function in add_menu_page?
- disable lightbox in a plugin [closed]
- How to maintain WordPress permalink structure with custom content with URL parameters?
- Need Help Creating a Multi-Step, Video-Guided Enrollment Site
- User specific content (posts) / limiting visibility
- Is there a way to include some external script to some or all pages in a wordpress site?
- Remove the ‘Press This’ Tool
- How wordpress plugin hooks works? [duplicate]
- Selling Downloadable Products [closed]
- How to delete remain data in WP database after deleting custom post via admin interface
- AdBlock blocks my non-advertising sidebar images [closed]
- How can I modify the colors of my theme for a single section of my site? [closed]
- How to generate a responsive output from plugin?
- Need help saving input fields for Security Deposit plugin in WC Vendors page
- WordPress Customise
- Looking for membership style plugin with edit option [closed]
- Take Elementor For Email FIeld Check if user is registered. IF not registered then register on woocommerece
- How to disable plugin capability : “create new category”