This thread is resolved. Here is a description of the problem and solution.
Problem:
You need to configure the WPML language switcher to redirect users between two separate WordPress domains (glginsights.com and glginc.cn) based on the selected language, while maintaining consistent permalinks.
Solution:
We recommend implementing a custom redirect using the
wpml_language_has_switched
hook. This hook activates after WPML switches the language context, allowing you to redirect users to the corresponding page on the other domain. Here is a basic example of how you can set this up:
add_action( 'wpml_language_has_switched', function( $lang ) { // Only run on frontend if ( is_admin() || wp_doing_ajax() ) return; $current_uri = $_SERVER['REQUEST_URI']; if ( $lang === 'zh' ) { wp_redirect( 'https://glginc.cn' . $current_uri ); exit; } elseif ( in_array( $lang, [ 'en', 'ja', 'ko', 'de' ] ) ) { wp_redirect( 'https://glginsights.com/' . $lang . $current_uri ); exit; } });
Ensure that both domains use matching permalinks and slugs, and adjust the language codes to match your WPML configuration. This solution is custom and may require further adjustments based on your specific setup.
If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket at WPML support forum.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
This topic contains 1 replies, has 0 voices.
Last updated by 1 month, 1 week ago.
Assisted by: Andreas W..