Skip to main content

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 / FlagDescription
PLUGIN...Plugin slug(s) to uninstall
--deactivateDeactivate the plugin before uninstalling
--skip-deleteRun uninstall hook but do NOT delete plugin files (default behavior)

Uninstall vs Delete vs Deactivate

ActionTurns off pluginRuns uninstall hookRemoves files
wp plugin deactivate
wp plugin uninstallIf 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

  1. Always back up the database before uninstalling data-heavy plugins (WooCommerce, ACF, Gravity Forms).
  2. Use --deactivate if you haven't already deactivated — required before uninstall on some plugins.
  3. Follow with wp plugin delete to remove plugin files from disk.
  4. Run wp db size before and after to verify data was removed.
  5. Check wp_options for orphaned rows after uninstalling poorly-coded plugins:
    wp db query "SELECT option_name FROM wp_options WHERE option_name LIKE '%old_plugin%';"

Troubleshooting

ProblemCauseFix
Error: Plugin not deactivatedPlugin still activeAdd --deactivate flag
Plugin data still in DB after uninstallPlugin doesn't implement uninstall.phpManually clean up with wp db query
Plugin not foundWrong slugUse 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