wp plugin uninstall
Overview
Properly remove a plugin by running its uninstall routine — which deletes all of the plugin's database tables, options, and custom data — before or in place of simply deleting the files.
What It Does
wp plugin uninstall triggers the plugin's uninstall.php or uninstall hook, which cleans up all plugin-specific data: database tables, wp_options entries, and custom post types registered by the plugin. By default it does not delete the plugin files — add --deactivate or combine with wp plugin delete to fully remove.
Syntax
wp plugin uninstall <plugin>... [--deactivate] [--skip-delete]
Arguments & Options
| Argument / Flag | Description |
|---|---|
PLUGIN... | Plugin slug(s) to uninstall |
--deactivate | Deactivate the plugin before uninstalling |
--skip-delete | Run uninstall hook but do NOT delete plugin files (default behavior) |
Uninstall vs Delete vs Deactivate
| Action | Turns off plugin | Runs uninstall hook | Removes files |
|---|---|---|---|
wp plugin deactivate | ✅ | ❌ | ❌ |
wp plugin uninstall | If active, must --deactivate first | ✅ | ❌ (by default) |
wp plugin delete | ✅ (forces) | ❌ | ✅ |
wp plugin deactivate --uninstall | ✅ | ✅ | ❌ |
| Full removal (recommended) | wp plugin deactivate + wp plugin uninstall + wp plugin delete | ✅ | ✅ |
Basic Usage
Uninstall (run cleanup hook, keep files)
wp plugin uninstall woocommerce
Deactivate first, then uninstall
wp plugin uninstall woocommerce --deactivate
Full removal: uninstall + delete files
wp plugin deactivate woocommerce
wp plugin uninstall woocommerce
wp plugin delete woocommerce
Expected Output
Ran uninstall procedure for 'woocommerce' plugin.
Success: Uninstalled 1 of 1 plugins.
Uninstall deletes plugin data permanently
Running a plugin's uninstall routine removes everything it created — tables like wp_woocommerce_*, all WooCommerce orders, products, and settings in wp_options. Back up your database before uninstalling any plugin with significant data.
Real-World Scenarios
Scenario 1: Full clean removal of an abandoned plugin
# 1. Backup
wp db export "pre_uninstall_$(date +%Y%m%d).sql"
# 2. Deactivate, run cleanup, remove files
wp plugin deactivate my-old-plugin
wp plugin uninstall my-old-plugin
wp plugin delete my-old-plugin
# 3. Verify it's gone
wp plugin list | grep my-old-plugin || echo "Plugin fully removed ✅"
Scenario 2: Cleanup a security-compromised plugin
# Remove a plugin that contained malicious code
wp plugin deactivate malicious-plugin
wp plugin uninstall malicious-plugin
wp plugin delete malicious-plugin
# After removal, verify core files
wp core verify-checksums
wp config shuffle-salts
Scenario 3: Clean uninstall for a migration (moving to different solution)
# Replacing old form plugin with Contact Form 7
wp plugin deactivate old-forms-plugin
wp plugin uninstall old-forms-plugin # Remove its DB tables
wp plugin delete old-forms-plugin # Remove its files
wp plugin install contact-form-7 --activate
Best Practices
- Always back up the database before uninstalling data-heavy plugins (WooCommerce, ACF, Gravity Forms).
- Use
--deactivateif you haven't already deactivated — required before uninstall on some plugins. - Follow with
wp plugin deleteto remove plugin files from disk. - Run
wp db sizebefore and after to verify data was removed. - Check
wp_optionsfor orphaned rows after uninstalling poorly-coded plugins:wp db query "SELECT option_name FROM wp_options WHERE option_name LIKE '%old_plugin%';"
Troubleshooting
| Problem | Cause | Fix |
|---|---|---|
Error: Plugin not deactivated | Plugin still active | Add --deactivate flag |
| Plugin data still in DB after uninstall | Plugin doesn't implement uninstall.php | Manually clean up with wp db query |
Plugin not found | Wrong slug | Use wp plugin list --field=name to find correct slug |
Quick Reference
wp plugin uninstall woocommerce # Run cleanup hook
wp plugin uninstall woocommerce --deactivate # Deactivate first then uninstall
wp plugin deactivate p && wp plugin uninstall p && wp plugin delete p # Full removal
Next Steps
wp plugin delete— remove plugin files from disk after uninstalling.wp plugin deactivate— deactivate without cleaning up data.wp db export— backup before uninstalling data-heavy plugins.