I think a good developer should provide the uninstallation in the safest and cleanest possible way.

I downloaded various plugins today to understand the process, but everything was very confusing. I found that many plugins are using both uninstall.php files and register_uninstall_hook(__FILE__, 'pluginprefix_function_to_run');

Is it correct?

because the link that I have provided above says that these two are two different methods. so what is correct using either registration hook or uninstall.php or both?

1 Answer 1


They’re just two different ways of doing the same thing. It’s up to you which one to use, or whether to use both. Neither is ‘correct’. Use whichever makes more sense to you with the structure of your plugin.

  • Thanks. You said to use both. How come it is possible - won't they conflict? Please enlighten if possible with an example. Oct 25, 2018 at 2:53
  • 1
    They'll just both run. There'll only be a conflict if you try to do the same thing in both. I don't know why you'd do that, but I'm not writing your plugin. Oct 25, 2018 at 3:00
  • Hi there, Can you write a sample uninstallation function in uninstall.php, if possible? Oct 25, 2018 at 3:25
  • 1
    No. There's one in your own link. Oct 25, 2018 at 3:30
  • 1
    @RichaSharma You were under the 15 rep minimum to cask upvotes, who knew.
    – kero
    Oct 25, 2018 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.