[wp-hackers] MU-compatbility with custom plugin tables?

Austin Matzko if.website at gmail.com
Mon Nov 30 22:06:20 UTC 2009

On Mon, Nov 30, 2009 at 4:02 PM, Derek Hogue <derek at amphibian.info> wrote:
> Hey all - recently I've been asked by several users to look into full
> MU-compatibility for my plugin GigPress. The problem is, GigPress uses
> 4 custom database tables to hold its data.
> So when it's installed, these tables are created with the current
> database prefix (say, wp_').  But if the plugin is installed as a site-
> wide plugin (in the 'mu-plugins' folder), when other users try to add
> data, it doesn't fly (trying to insert into tables that don't exist,
> like 'wp_2_gigpress_shows').
> Does MU offer any sort of hook for site-wide-plugins to automatically
> create these tables for each individual blog when it's created? Or are
> plugins which use their own DB tables only compatible when put into
> the 'plugins' folder in MU?

WPMU has $wpdb->base_prefix, which would be "wp_" in your example, and
the standard WordPress $wpdb->prefix, which changes depending on the
current blog (changing to things like "wp_2_").  Check for and use
$wpdb->base_prefix to set up site-wide tables.

More information about the wp-hackers mailing list