Skip to content

Instantly share code, notes, and snippets.

@harisrozak
Last active April 15, 2021 04:37
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 harisrozak/b21f76f26116056d9a38e99397f048e8 to your computer and use it in GitHub Desktop.
Save harisrozak/b21f76f26116056d9a38e99397f048e8 to your computer and use it in GitHub Desktop.
Main multisite-site on app.example.com. Also fixed `cookies` related error on child-sites login
<?php
/**
* Modify multisite childs subdomain path
* The main multisite path is on app.example.com
* And then it's children should be on foo.example.com, bar.example.com, etc.
* This code should be located on mu-plugins folder
*/
if ( ! function_exists( 'harisrozak_change_site_subdomain' ) ) {
function commercioo_change_site_subdomain( $data ) {
$data['domain'] = preg_replace( '/(.*).app.(.*)/', '$1.$2', $data['domain'] );
return $data;
}
}
add_filter( 'wp_normalize_site_data', 'harisrozak_change_site_subdomain', 10, 1 );
<?php
/**
* Fix error on child-site login with `Cookies` error message
* Put this line on wp-config.php
*/
define( 'COOKIE_DOMAIN', strtolower( stripslashes( $_SERVER['HTTP_HOST'] ) ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment