Issue
Does anyone know how to force subdomain multisite to retain the URL schema (specifically https) when a new subsite is created?
By default, it creates subsites with the "siteurl" and "home" options urls with "http://".
There are a few lines in ms-functions.php that explicitly tell subsite NOT to use the schema, so I'm wondering what the best way to change that is without modifying the source. Thanks!
Solution
We use the Multisite Clone Duplicator plugin, and I was able to write a function that hooks into the plugin during the cloning process, avoiding having to touch the core code.
if ( ! function_exists( 'mucd_after_copy_data' ) ) {
function force_https($from_site_id, $to_site_id) {
$site_url = get_site_url($to_site_id);
$https_site_url = str_replace( 'http://', 'https://', $site_url );
update_blog_option( $to_site_id, 'siteurl', $https_site_url );
update_blog_option( $to_site_id, 'home', $https_site_url );
}
add_action('mucd_after_copy_data', 'force_https', 10, 2 );
}
Answered By - wsizoo Answer Checked By - Cary Denson (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.