Skip to content

Instantly share code, notes, and snippets.

@nikitasinelnikov
Last active May 12, 2021 11:54
Show Gist options
  • Save nikitasinelnikov/82994a80638d9fed84f15f0c3c95b4cc to your computer and use it in GitHub Desktop.
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
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