How to change all blog settings? (etc:Permalinks)
How to change all blog settings? (etc:Permalinks)
http://mu.wordpress.org/forums/topic.php?id=9265
First post has a plugin. Further down MrBrian shared his code which is what I use.
I should mention I revised the code a bit to use the proper functions. This only applies to newly created blogs. If you want to change all the blogs, your going to have to edit WPMU's upgrade script to call the function and then run it like i did once.
function change_newblog_defaults( $blog_id, $user_id )
{
global $wpdb, $current_site, $wp_rewrite;
//--change permalink structure
switch_to_blog($blog_id);
$permalink_structure = '/%category%/%postname%/';
$wp_rewrite->set_permalink_structure($permalink_structure);
$wp_rewrite->flush_rules();
$wpdb->query( "UPDATE {$wpdb->terms} SET name = 'Articles', slug = 'articles' WHERE term_id = 1" );
//--end
//--change default blogroll
wp_delete_link(1); //delete Wordpress.com blogroll link
wp_delete_link(2); //delete Wordpress.org blogroll link
wp_insert_link(array('link_name' => $current_site->domain, 'link_url' => 'http://' . $current_site->domain . $current_site->path));
//--end
restore_current_blog();
}
add_action( 'wpmu_new_blog', 'change_newblog_defaults', 10, 2 );
Thanks MrBrian.
Do you release your plugins anywhere, so we can when they are updated ?
At the moment, I don't. When I get some time i'll post some of my stuff to wpmudev.org.
Before the competition closes, I hope :)
and that's the wpmu plugin competition over at wpmu.org. :)
MrBrain, please do submit a bunch.
MrBrian with your code I'd like to set for example, the default Discussion settings of all new blogs to disable comment moderation and also set the default Avatar to an Identicon. Any pointers?
Most defaults inside of the options table can be changed like this:
function change_wpmu_defaults(){
add_option('avatar_default', 'mystery');
add_option('comment_moderation', '0');
}
add_action('populate_options', 'change_wpmu_defaults');