mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
Adds correct profile url to WPML language switcher
This commit is contained in:
@@ -33,4 +33,32 @@ add_filter('um_core_page_id_filter','um_core_page_id_filter');
|
||||
function um_core_page_id_filter( $page_id ){
|
||||
|
||||
return $page_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds correct profile url to WPML language switcher
|
||||
*/
|
||||
add_filter( 'icl_ls_languages','um_core_page_wpml_permalink', 10, 1 );
|
||||
function um_core_page_wpml_permalink( $array ){
|
||||
global $ultimatemember, $sitepress;
|
||||
if( ! um_is_core_page("user") ) return $array;
|
||||
if( ! defined("ICL_LANGUAGE_CODE") ) return $array;
|
||||
if( ! function_exists('icl_object_id') ) return $array;
|
||||
|
||||
// Permalink base
|
||||
$permalink_base = um_get_option('permalink_base');
|
||||
|
||||
// Get user slug
|
||||
$profile_slug = get_user_meta( um_profile_id(), "um_user_profile_url_slug_{$permalink_base}", true );
|
||||
$current_language = ICL_LANGUAGE_CODE;
|
||||
foreach ( $array as $lang_code => $arr ) {
|
||||
$sitepress->switch_lang( $lang_code );
|
||||
$user_page = um_get_core_page("user");
|
||||
|
||||
$array[ $lang_code ]['url'] = "{$user_page}{$profile_slug}/";
|
||||
}
|
||||
|
||||
$sitepress->switch_lang( $current_language );
|
||||
|
||||
return $array;
|
||||
}
|
||||
Reference in New Issue
Block a user