If you are using Polylang plugin to support multi language on your site, you will need to user profile switch to user id and nav. please add following code to support navigate user.
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
// check if polylang exist & enabled
if ( is_plugin_active( 'polylang/polylang.php' ) ) {
//plugin is activated
add_filter('pll_the_languages', 'my_dropdown', 10, 2);
function my_dropdown($output, $args) {
if(!empty($_GET['id'])){
$id = $_GET['id'];
}
else{
$id = '';
}
if(!empty($_GET['nav'])){
$nav = $_GET['nav'];
}
else{
$nav = '';
}
$translations = pll_the_languages(array('raw'=>1));
$output = '';
$output .= '<div class="btn-group" role="group">
<ul class="dropdown-menu">';
foreach ($translations as $key => $value) {
$output .= '<li><a href="'.$value['url'].'?id='.$id.'&nav='.$nav.'"><img src="'.$value['flag'].'" alt="'.$value['slug'].'"> ' .$value['name'].'</a></li>';
}
$output .= '</ul></div>';
return $output;
}
}
