Update siteurl and home in multisite subsites to https

I want rewrite the siteurl and home options on multisite subsites.

In wp-admin/option.php this is it:

if ( !is_multisite() ) {
if ( !defined( ‘WP_SITEURL’ ) )
$whitelist_options[‘general’][] = ‘siteurl’;
if ( !defined( ‘WP_HOME’ ) )
$whitelist_options[‘general’][] = ‘home’;
/** etc… **/
}

Now I try updating this options in my theme’s functions.php file:

add_action( ‘after_setup_theme’, ‘update_forceurl’ );
function update_forceurl() {
$xsiteurl = get_site_url();
$find = array( ‘http://’ );
$replace = ‘https://’;
$finalurl = str_replace( $find, $replace, $xsiteurl );

update_option( ‘siteurl’, $finalurl );
update_option( ‘home’, $finalurl );
}

Read more here:: Update siteurl and home in multisite subsites to https

Leave a Reply

Your email address will not be published. Required fields are marked *