I have been trying to figure this out for the past couple of hours, mostly by using some code snippets found online, but since my PHP skills are quite rusty I haven't been able to put it together. If someone would be willing to take a couple of minutes to write this out, maybe make a blogpost out of it, I would really appreciate it.

So the idea is that the file is uploaded to the folder where Wordpress is installed via FTP, and after accessing it it's supposed to do the following:

  1. Get database credentials from wp-config.php
  2. Completely wipes the database using the credentials
  3. Deletes the Wordpress install folder in which it resides

I think it would be really useful for removing old Wordpress installs from a server, so I'm quite surprised I haven't been able to find something like this anywhere. Thank you!


You haven't been able to find anything like that because it is impossible to do as in 95% of the servers the web server do not have the permission to delete the files that were uploaded via FTP.

In addition it takes only two commands in the command line interface to do this and it will actually be slower to do it your way.

Edit: For a moment I forgot you can use the filesystem API to delete files, still it amounts to connecting via an FTP program and you will probably be restricted to delete the files sequentially which can really take long time.

  • Than how are plugins like this wordpress.org/plugins/wp-filemanager able to do it without requesting any sort of FTP credentials? – Andrew Apr 1 '15 at 11:44
  • 1
    You are right, doing it via SSH is the way to go. WP-CLI and the command wp db could be used to handle the database. Removing directories can be done via rm. Combining it into one shell script shouldn't be to hard. @Andrew – Nicolai Apr 1 '15 at 11:45
  • Unfortunately I do not have SSH access. – Andrew Apr 1 '15 at 11:51
  • 1
    Really, honestly, you probably should change your host or hosting plan, because if you are going to manage multiple - maybe even a lot of - WordPress installations it is invaluable. @Andrew – Nicolai Apr 1 '15 at 11:55
  • I know and this is not my main server, I got a DigitalOcean VPS a long time ago. I'm just trying to figure out a solution for the current circumstances. – Andrew Apr 1 '15 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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