Skip to content

Instantly share code, notes, and snippets.

@nikitasinelnikov
Created May 12, 2021 11:46
Show Gist options
  • Select an option

  • Save nikitasinelnikov/02eabe3c6c62e8a354063d53251b5572 to your computer and use it in GitHub Desktop.

Select an option

Save nikitasinelnikov/02eabe3c6c62e8a354063d53251b5572 to your computer and use it in GitHub Desktop.
Ultimate Member - Profile Completeness: Change field label based on the current language via WPML plugin
function my_custom_fields_array_for_titles( $fields, $key ) {
if ( UM()->external_integrations()->is_wpml_active() ) {
global $sitepress;
$language_code = $sitepress->get_current_language();
if ( $language_code == 'zh-hant' ) {
switch ( $key ) {
case 'coach-mentoring_specialties':
$fields[ $key ]['label'] = '導師(Coach-Mentoring)特長';
break;
case 'counseling_specialties':
$fields[ $key ]['label'] = '輔導(Counseling)特長';
break;
case 'about_me':
$fields[ $key ]['label'] = '關於我';
break;
case 'user_profile':
$fields[ $key ]['label'] = '我的個人簡介檔案';
break;
}
} elseif ( $language_code == 'zh-hans' ) {
switch ( $key ) {
case 'coach-mentoring_specialties':
$fields[ $key ]['label'] = '导师(Coach-Mentoring)特长';
break;
case 'counseling_specialties':
$fields[ $key ]['label'] = '辅导(Counseling)特长';
break;
case 'about_me':
$fields[ $key ]['label'] = '关于我';
break;
case 'user_profile':
$fields[ $key ]['label'] = '我的个人简介档案';
break;
}
}
}
return $fields;
}
add_filter( 'um_profile_completeness_fields_array_for_titles', 'my_custom_fields_array_for_titles', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment