WP Multi-Site with Multi-tenant feature

Job ID: 38236772

Budget: $30 – $250 USD

I need a WordPress Multi-Site with Multi-tenant capability (a different database for each child-site)



The idea is to allow each user to have a separate database base while using the same WP codebase.



Every WP dev. must be familiar with how multisite works, it’s a standard WordPress install (12 tables for the main WP site) plus +6 tables for the network site functionality.



Each new child site creates 12 additional tables differentiated by adding a new id to the table prefix name:



wp__commentmeta
wp__comments
wp__links
wp__options
wp__postmeta
wp__posts
wp__termmeta
wp__terms
wp__term_relationships
wp__term_taxonomy
wp__usermeta
wp__users




So the main site



wp_1_options
wp_1_postmeta
wp_1_posts
wp_1_termmeta
wp_1_terms
wp_1_term_relationships
wp_1_term_taxonomy
wp_1_usermeta
wp_1_users…


Child-site

wp_2_options
wp_2_postmeta
wp_2_posts
wp_2_termmeta
wp_2_terms
wp_2_term_relationships
wp_2_term_taxonomy
wp_2_usermeta
wp_2_users…


And so on for each new site…We need to have a single child-site for each user.



PROBLEM: This isn’t scalable, after 10 sites the table becomes too big to manage.



I need a way for the Worpress Multisite to be able to read the child-site tables from a different database, (Multi-tenant)

The multisite is installed in a sub-domain with this format:

**subdomain.domain.com/username



Each new child site will be auto-created created with the username in the URL (this is already taken care of)



The MySQL database is automatically created also (this is also done)



There are a couple of repos I found that I tried to set up and failed.



WP Multitenant

https://github.com/troychaplin/wp-multitenant



Ludicrus

https://github.com/stuttter/ludicrousdb



I also found a Codecanyon PHP script, but it doesn’t work for WP

https://codecanyon.net/item/multisass-multitenancy-multipurpose-website-builder-sass/41892997#





The main task is to solve: the PHP connection between the WP Multisite Childsite ⇔ Child Database at scale.



In other words, I edit the configuration file with the (1) URL path / (2) db name / (3 )db user / (4) db pass of another child-site and the main site should be able to recognize that if it was added to the network database.



The second step would be to set up this dynamically (adding o removing the lines of code related to each child-site URL as they are created or deleted), but that’s a later problem.
Related categories: PHP WordPress Web Hosting Backend Development