Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm working on plugin that creates and stores some data in database table (using global $wpdb->base_prefix). In WordPress multisite I want sub-website owners to have access only to data that they've created. What is the best way to handle this? Should I create new table for each sub-website, or add "blog_id" column to table and check it every time?

Thanks for help.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

use the API, the functions of WordPress for save data and check before, it is an Multisite install; thats all. The first example is only for check, is the activated as network wide.

// if is active in network of multisite
if ( is_multisite() && isset($_GET['networkwide']) && 1 == $_GET['networkwide'] ) {
    add_site_option( 'my_settings_id', $data );
} else {
    add_option( 'my_settings_id', $data );
}

The follow example check for mutlisite and if the plugin active in complete network.

if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
    $values = get_site_option( 'my_settings_id' );
else
    $values = get_option( 'my_settings_id' );

Also you can check this in each blog and save the data in the tables of each blog.

*the examples was from this post

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.