[wp-hackers] populate_option : wpmu-upgrade vs freshly created blog

Potkanski, Jason jpotkanski at tribune.com
Mon Mar 22 19:29:13 UTC 2010

The Populate_options hook is called before the actual blog defaults are stored. Any defaults set here will just get overridden with schema defaults.

If you are looking for how to set default blog options programmatically, hook wpmu_new_blog.

Here is a code sample on how to hook into wpmu_new_blog:

add_action( 'wpmu_new_blog', 'set_default_options', 10 , 2 );

function set_default_options($blog_id, $user_id) {

function set_default_general_settings($blog_id) {
    update_blog_option($blog_id, 'timezone_string', 'America/New_York');

I set defaults for serialized plugin data like recaptcha as well. It's a pretty simple technique.

There is a "Blog Defaults" MU plugin out there as well.


Jason Potkanski
Tribune Technology

On 3/22/10 10:53 AM, "Raphaël Droz" <raphael.droz at gmail.com> wrote:

All is in the title,
while I would like to change the default options of a blog  I observed
that the populate_option hook is also used at upgrade.

Should I use some kind of workaround like comparing the creation date ?
Or should I forget about the wpdb->query and use update_option's in the
wpmu_new_blog hook which, apparently until now, is only used at the blog
creation time.
In this latter case, I would be out-context and, to, eg, switch the theme or
add a post, I would have to switch_blog() again.
wp-hackers mailing list
wp-hackers at lists.automattic.com

More information about the wp-hackers mailing list