Title: WP 3.0,  initialize data while network activating a plugin
Last modified: August 19, 2016

---

# WP 3.0, initialize data while network activating a plugin

 *  [laceous](https://wordpress.org/support/users/laceous/)
 * (@laceous)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/wp-30-initialize-data-while-network-activating-a-plugin/)
 * Hi, I’m trying to determine if the following issue is by design or a possible
   bug.
 * Assume you have a 3.0 multisite install. A plugin you’re trying to activate initializes
   some data in the database like this:
 *     ```
       function myplugin_activate() {
         update_option('key', 'value');
       }
       register_activation_hook( __FILE__, 'myplugin_activate' );
       ```
   
 * (Obviously this is a very simple example, but you get the idea)
 * If you go to every site in your network and activate the plugin then the option
   will be added to the database for each site (wp_options, wp_2_options, wp_3_options,
   etc). However, if you choose the “network activate” option then the option is
   only added to the database for the current site (e.g. wp_2_options). Is this 
   a bug or by design? I can understand how looping through each site in your network
   might be expensive, but maybe cron jobs could be generated?
 * If this is by design, are there any recommended “best practices” for plugin authors?
 * An obvious work-around is to not use the “active_” hook, but instead check for
   an option in the database on plugin/page load (e.g. get_option). If the data 
   doesn’t exist then go ahead and initialize it.
 * Also, in certain cases you might want to use the get|add|update|delete_site_option
   functions instead (which uses the wp_sitemeta table for network-wide options).
 * Thanks.

Viewing 1 replies (of 1 total)

 *  [Andrea Rennick](https://wordpress.org/support/users/andrea_r/)
 * (@andrea_r)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/wp-30-initialize-data-while-network-activating-a-plugin/#post-1450946)
 * I *think* (from fuzzy memory here) what is supposed to happen is they plugin 
   gets activated for real when the owner of the blog logs in to the backend of 
   their blog (site).
 * Depending on what the plugin does, you might consider placing it in the mu-plugins
   folder instead.

Viewing 1 replies (of 1 total)

The topic ‘WP 3.0, initialize data while network activating a plugin’ is closed 
to new replies.

## Tags

 * [activate](https://wordpress.org/support/topic-tag/activate/)
 * [multisite](https://wordpress.org/support/topic-tag/multisite/)

 * In: [Alpha/Beta/RC](https://wordpress.org/support/forum/alphabeta/)
 * 1 reply
 * 2 participants
 * Last reply from: [Andrea Rennick](https://wordpress.org/support/users/andrea_r/)
 * Last activity: [16 years, 2 months ago](https://wordpress.org/support/topic/wp-30-initialize-data-while-network-activating-a-plugin/#post-1450946)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
