[wp-hackers] Network activate, but only create one table

Alex Hempton-Smith hempsworth at gmail.com
Mon Jan 3 13:40:10 UTC 2011


Hi all,

I'm working on the next version of BuddyPress Like, which will be creating
it's work table. I want it to work with MultiSite, but I only want there to
be one database table for the whole network rather than a separate one for
each site. This is so I can more easily bring up stats of the most 'liked'
content for the whole network.

Currently, I'm using this code to create the database table, pretty normal:

 $table_name = $wpdb->prefix . 'likes';
>
> if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
>
> $sql[] = "CREATE TABLE $table_name (...


Which works fine, but when I network activate the plugin it's creating
wp_likes, wp_2_likes etc.

How would I modify how I'm doing things to still respect any custom table
prefix that might be set, but only have one table for the whole network?

-- Alex


More information about the wp-hackers mailing list