Open

Topic Tags: Language Switcher

Symptoms

Using the language switcher to navigate to the secondary language(s) page does not work on the user’s page.

Workaround

To resolve this issue add the snippet below to the functions.php file found in your theme’s folder.

bbPress user language switcher fix
add_filter( 'icl_ls_languages', 'bbpress_user_ls_fix' );

function bbpress_user_ls_fix( $languages ) {
        global $wp_query;

        if ( bbp_is_single_user_profile() ) {
                foreach ( $languages as $code => $language ) {
                        $home = trailingslashit( get_home_url() );
                        do_action( 'wpml_switch_language', $code );
                        $lang_url = trailingslashit( apply_filters( 'wpml_home_url', $home ) );
                        $url = str_replace( $home, $lang_url, bbp_get_user_profile_url() );
                        $languages[ $code ]['url'] = $url;
                }
                do_action( 'wpml_switch_language', ICL_LANGUAGE_CODE );
        }
        return $languages;
}

22 Responses to “bbPress – Language switcher not working on user pages”

Leave a Reply

Please leave here comments about this page only.
For technical support and feature suggestions, head to our forum. We are waiting there!

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>