Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Created April 9, 2014 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpsmith/10307361 to your computer and use it in GitHub Desktop.
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
<?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