Last active
May 12, 2021 11:54
-
-
Save nikitasinelnikov/82994a80638d9fed84f15f0c3c95b4cc to your computer and use it in GitHub Desktop.
Ultimate Member: Change view field value based on the current language via WPML plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function um_custom_field_view_wpml( $res, $data, $type ) { | |
if ( UM()->external_integrations()->is_wpml_active() ) { | |
global $sitepress; | |
$language_code = $sitepress->get_current_language(); | |
if ( $language_code == 'zh-hant' ) { | |
switch ( $data['metakey'] ) { | |
case 'gender': | |
$res = $res == 'Female' ? '女' : '男'; | |
break; | |
} | |
} elseif ( $language_code == 'zh-hans' ) { | |
switch ( $data['metakey'] ) { | |
case 'gender': | |
$res = $res == 'Female' ? '女': '男'; | |
break; | |
} | |
} | |
} | |
return $res; | |
} | |
add_filter( 'um_view_field', 'um_custom_field_view_wpml', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment