Created
April 15, 2015 07:04
-
-
Save sunnyluthra/e0ab92e2007b19423d6b to your computer and use it in GitHub Desktop.
Alter WP Multisite table after new blog creation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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