WordPress.org

Forums

Global database tables. (2 posts)

  1. comstar
    Member
    Posted 4 years ago #

    I run a number of sites (different domains) that share some common data between them. Below I am using the example of the media galleries, but assume it could be posts or other table information that could be 'shared':

    Site-1 has media galleries of type-a
    Site-2 has media galleries of type-b and needs to show type-c
    Site-3 has media galleries of type-c and needs to show type-a
    Site-4 wants to show type-a,type-b, and type-c media galleries.

    I'm wondering if there were a database plug-in that would allow this type of behavior. Anyone know? Maybe something that can address the global data with a table tag wp_ (globals), site1_ (site 1 specific), etc...

  2. stvwlf
    Member
    Posted 4 years ago #

    This can be done with the users table to share users between installations. Not sure if it extends beyond that. For it to work with users all the installations must use the same database. That is, each installation would have its own set of WP tables. Each set would have a different table name prefix.

    So instead of wp_posts, one might be wp1_posts, the next wp2_posts, etc.

    I'm pasting info on how to set users up this way so you have a place to further research if this can be applied to other tables. the issue you will run into is you can't just have a part of the posts or options table shared between sites. its all or nothing. I am not sure it can be done anyway, but if it can what is below is a starting place to research.
    ========================

    Share users between two blogs
    Here are some brief notes on how to share a user table between more than one installation. All installations must be in the same database, using different table name prefixes. The table name prefix is set in each site's wp-config.php file. Each site has a different table name prefix

    choose one of them to be the master user table. Then do this in both wp-config.php files:
    define(CUSTOM_USER_TABLE,'wp_users');
    define(CUSTOM_USER_META_TABLE,'wp_usermeta');
    Replace the wp_ with the prefix you want.

    In other words, you designate the user table from ONE installation as the master user table which will be used by the other installations instead of their own user table. This PHP code must go in the wp-config.php file in all the installations that you want sharing a single user table. You can have more than two installations set up the same way. Their tables must all be in a single database however.

Topic Closed

This topic has been closed to new replies.

About this Topic