update_option: siteurl and home in multisite subsites not working

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’;

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://’, ‘https://’ );
$replace = ”;
$finalurl = str_replace( $find, $replace, $xsiteurl );

update_option( ‘siteurl’, ‘https://’ . $finalurl . ” );
update_option( ‘home’, ‘https://’ . $finalurl . ” );

}`

Any idea why not working this?

Read more here:: update_option: siteurl and home in multisite subsites not working

Leave a Reply

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