Automating WordPress subdirectory creation with isolated databases for client-specific sections

I’m working on a project for my drone service company. We want to give each client their own section on our website. I’ve looked at a few ways to do this:

  1. Using pages with a membership plugin
  2. Setting up a multisite network
  3. Making separate WordPress installs in subdirectories

But none of these quite fit what we need. We want each client section to be totally separate, with its own database. And we need a way for our admins to set these up easily.

What we’re looking for is a system where an admin can:

  • Click a button to make a new WordPress install for a client
  • Enter details like the client’s name and URL
  • Set up a new database for that client
  • Add some custom content to the new site

Is there a way to do all this automatically? How can we make it happen without a ton of manual work for each new client? Any ideas would be super helpful!

hey there davidw, have you looked into using WP-CLI with a custom script? you could set up a bash script that takes client info as input, creates a new subdirectory, sets up a fresh WP install with its own DB, and even adds some initial content. might take some coding but could save tons of time in the long run!

Have you considered using Docker containers for this setup? I’ve implemented a similar system for a client using Docker, and it works like a charm. Each client gets their own isolated container with WordPress and a separate database.

We created a custom Docker image with WordPress pre-installed and some scripts to handle the initial setup. When an admin needs to create a new client site, they run a command with the client’s details. The system spins up a new container, sets up the database, and even populates some initial content.

The beauty of this approach is the isolation and ease of management. You can easily backup, move, or delete client sites without affecting others. It also scales well if you need to add more resources for specific clients.

It does require some initial setup and familiarity with Docker, but the long-term benefits are substantial. You might want to look into Docker Compose for orchestrating these containers efficiently.

I actually tackled a similar challenge for a client last year. We ended up building a custom plugin that integrates with WordPress’s core functions to automate the process. Here’s what worked for us:

We created a form in the admin panel where you input client details. The plugin then uses WordPress’s built-in functions to create a new site in a subdirectory, set up a separate database, and install a fresh WP instance.

The tricky part was automating database creation, but we used WordPress’s wpdb class to handle SQL operations. For content population, we built a template system where you can pre-define structures and the plugin fills in client-specific details.

It took some effort to set up initially, but now it’s a breeze to create new client sections. Just fill out a form, click a button, and everything’s ready in minutes. Might be worth exploring if you have some development resources available.