Skip to content

Instantly share code, notes, and snippets.

@sunnyluthra
Created April 15, 2015 07:04
Show Gist options
  • Save sunnyluthra/e0ab92e2007b19423d6b to your computer and use it in GitHub Desktop.
Save sunnyluthra/e0ab92e2007b19423d6b to your computer and use it in GitHub Desktop.
Alter WP Multisite table after new blog creation
<?php
function alter_table(){
global $wpdb;
$sql = "ALTER TABLE ".$wpbd -> posts." ADD `likes_count` INT( 11 ) NOT NULL DEFAULT '0'"
$wpdb -> query($sql);
}
function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
switch_to_blog( $blog_id );
alter_table();
restore_current_blog();
}
add_action( 'wpmu_new_blog', 'on_create_blog', 10, 6 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment