Created
April 9, 2014 19:46
-
-
Save wpsmith/10307361 to your computer and use it in GitHub Desktop.
PHP: How to Allow Posts to Posts to Install on New Blog/Site Creation with Users being Editors
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 | |
add_action( 'wpmu_new_blog', 'wps_install_p2p', 5, 6 ); | |
/** | |
* Create P2P table on site creation regardless of admin presence. | |
* | |
* @see P2P_Tools_Page::maybe_install() | |
* @author Travis Smith <wpsmith.net> | |
* | |
* @param int $blog_id Blog ID. | |
* @param int $user_id User ID. | |
* @param string $domain Domain. | |
* @param string $path Path to domain. | |
* @param int $site_id Site ID. | |
* @param array $meta Site Meta. | |
* | |
*/ | |
function wps_install_p2p( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { | |
switch_to_blog( $blog_id ); | |
$current_ver = get_option( 'p2p_storage' ); | |
if ( $current_ver == P2P_Storage::$version ) { | |
return; | |
} | |
P2P_Storage::install(); | |
update_option( 'p2p_storage', P2P_Storage::$version ); | |
restore_current_blog(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment