This thread is resolved. Here is a description of the problem and solution.
Problem:
If you're trying to switch languages on a profile page using the WPML language switcher, but instead of being redirected to the corresponding profile page in the other language, you are redirected to a generic profile page or a warning page.
Solution:
We recommend backing up your site before making any changes. Then, edit your theme's functions.php file and add the following code at the end:
// WPML Workaround for compsupp-8195<br />// Preserve WPUM profile sub-path when switching languages with WPML.<br />add_filter( 'icl_ls_languages', function( $languages ) {<br /> // Only run if WPUM<br /> if ( ! function_exists( 'wpum_get_core_page_id' ) ) {<br /> return $languages;<br /> }<br /><br /> // Get profile info from query vars<br /> $queried_profile = get_query_var( 'profile', false );<br /> if ( ! $queried_profile ) {<br /> return $languages;<br /> }<br /><br /> // Build the trailing path from query vars<br /> $trailing = '/' . rawurlencode( $queried_profile );<br /><br /> // Add tab and pagination if present<br /> $tab = get_query_var( 'tab' );<br /> if ( $tab ) {<br /> $trailing .= '/' . rawurlencode( $tab );<br /> }<br /> $paged = get_query_var( 'paged' );<br /> if ( $paged ) {<br /> $trailing .= '/page/' . rawurlencode( $paged );<br /> }<br /><br /> // Append to each language URL<br /> foreach ( $languages as $key => $lang ) {<br /> if ( empty( $lang['url'] ) ) {<br /> continue;<br /> }<br /> $languages[$key]['url'] = rtrim( $lang['url'], '/' ) + $trailing;<br /> }<br /><br /> return $languages;<br />} );This solution might be outdated or not applicable to your case. 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 this does not resolve your issue, please open a new support ticket.
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 2 replies, has 0 voices.
Last updated by 4 weeks, 1 day ago.
Assisted by: Lucas Vidal de Andrade.