A client is paying good money for a custom plugin.

I want them to have the ability to deactivate it if needed (testing) but I'm worried that they might accidentally hit that "delete" link by mistake. I know I did once during development.

It's not like they could just reinstall again from the repository.

I was wondering, if I could force the code to die() in the uninstall hook, would this prevent the deletion of the plugin itself?

I know I could just try it, and find out, but then I'd miss the opportunity to share this thought out loud with the community.

Also, by asking here, maybe someone could recommend a BETTER way than just halting the script.

  • maybe the downvote is not in place, but I have an automatic puking reflex when I read that someone want to deprive their clients/user the ability to manage their site however they see fit for the following reason 1. It is not moral unless you stated that in the contract. 2. It is technically not possible unless you make sure that they can not have root access to the web server – Mark Kaplun Aug 9 at 18:00
  • Of course FTP is always possible, and I don't want them to NOT be able to remove it if they really wanted to. I was just worried about the "accidental" deletion. The delete link is just way too easy to hit. Maybe a Javascript popup would be best to confirm. Bind it to the "deactivate" button. (can't bind it to delete once the plugin is deactivated) – De Coder Aug 9 at 18:56
  • 1
    if the user don't need to manage plugins to work, you can create a new role without the capability delete_plugins. – Kaperto Aug 9 at 19:55
  • are you also protecting the users from changing some setting value from 10 to 20? The only protection is for the user to have good backup. – Mark Kaplun Aug 9 at 20:01
  • Changing a value from 10 to 20, is quite a bit different that them accidentally deleting a custom plugin they paid to have built. So you're saying if they delete this plugin without backups, it's their own fault/problem. I try to be a little more protective of my clients than that, and was looking for a way to add one extra step to protect them from themselves. (I accidentally deleted it myself, while working on it, so it IS easy to do. The link said Delete, I was thinking Deactivate.) Yet, you downvote me for looking at proactive options... – De Coder Aug 9 at 20:57

Multiple alternate suggestions to achieve your objective:

  1. make the plugin a 'must-use' https://codex.wordpress.org/Must_Use_Plugins, they do not apply exclusively to multi-site. Can use them in normal wp.
  2. give the client a customised role (as Kaperto suggested) that excludes 'delete-plugins'
  3. Name the plugin something like 'Essential Plugin'. Add 'Do not delete in the description' & Educate the client & Make sure there are backups. Have the backups emailed to the client weekly ;) so they aware of them.

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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