Please make sure to update to WPML 4.3.5 and check our list of Known Issues before reporting

Hi, Amit here, I am the WPML Support Manager, our current ticket queue is high, update your WPML plugins and make sure you meet the minimal requirements for running WPML before reporting an issue please - many tickets are resolved doing that

Please look at our updated list of Known Issues and you can also use our support search to find helpful information and of course review our documentation before opening a ticket.

If you do need to open a ticket please make sure to provide us with all the needed information as described in this page

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to translate and display user custom fields created with Toolset types.

Solution:

For anyone, who landed here with the exact same problem. Here the steps for adding Types custom-user-fields to WPMLS string-translation:

1) Put this filter into functions.php and add ALL user-fields, which should be translated:

add_filter( 'wpml_translatable_user_meta_fields', 'add_usermeta', 99);
function add_usermeta( $fields ) {
    $fields = array('description','wpcf-my-custom-field');
    return $fields;
} 

2) Add the shortcode for displaying the user-fields in functions.php

add_shortcode( 'user-meta', 'user_meta_func');
function user_meta_func($atts) {
  $key = $atts['key'];
  $id =  $atts['id'];
  return get_the_author_meta($key, $id);
}

3) Add the shortcode in Toolset (Settings > Frontend > Shortcode-Arguments)
4) Add the shortcode wherever your fields should appear (in View, Layout, Page ...)

[user-meta id="[wpv-user field='ID']" key="description"]
[user-meta id="[wpv-user field='ID']" key="wpcf-my-custom-field"]

Relevant Documentation:

This topic contains 22 replies, has 2 voices.

Last updated by Yvette 2 years, 7 months ago.

Assigned support staff: Yvette.

Author Posts
April 27, 2017 at 6:21 pm #1263732

Diana

I am trying to translate users with the role editor and show their infos as "business-cards" on Frontend. I'm working with WPMLs string-translation and Toolset Types and Views. I got the domain "authors" working for all these strings. There I translated all my user-meta but on the English site, the translated strings aren't showing. I did it this way:

* I created custom user-fields in Toolset Types and assigned them to all editors
* I made a Toolset View for showing all my editors as a list in Frontend
* In WPML-string-translation I marked "translation for user of type: editor"
* Then all my standard-user-fields showed off under the domain "authors"
* For translating the custom user-fields, which I created with Toolset Types, I added custom code to functions.php as described in this post: https://wpml.org/forums/topic/how-do-i-translate-the-contents-of-fields-in-the-user-profile/
* Then also my custom-user-fields appeared in the string-translation-list of domain "authors"
* I translated every string, marked as finished.

But the Frontend shows all the user-infos in my standard-language German, instead of English. I already tried to:

* "Scan themes for strings" in WPMLs theme- and plugin-localization
* In WPMLs Support-Troubleshooting: Clear cache, delete ghost-entries
* Deleted all translated strings in Domain "authors", reloaded them and translated them again

Nothing worked. For all of my other views, which are showing other content (as pages or custom post types) the English Translation is automatically assigned to the English page. But for any reason in this view of user-fields, that doesn't work. There is still my German standard-language.

Is there a trick to that? Or do I miss something?
Please for help!

April 28, 2017 at 7:49 am #1264044

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Hello

I´ll be helping you with this issue.

1. Could you post the code that you added to your functions.php here?

2. Clarification
2.1 You wrote: "..the Frontend shows all the user-infos in my standard-language German, .."
Does this include both the custom fields as well as the standard user-meta fields?

3. Technical Information on you environment
Could you please provide information about your environment by following thsese steps: http://wpml.org/faq/provide-debug-information-faster-support/

Thank you.

April 28, 2017 at 9:41 am #1264133

Diana

Hi Yvette!

1. Here's the code I've added to functions.php:

add_filter( 'wpml_translatable_user_meta_fields', function( $fields ) {
    $fields = array('wpcf-team-pos', 'wpcf-team-zitat', 'wpcf-team-aufgaben', 'wpcf-team-ausbildung');
    return $fields;
} );

2. Yes, both of them aren't showing up, both of them are in standard-language. And I have two separate views, which are showing different layouts for the user-information. And on both views, they are in standard language.

3. Did so now.

In my Toolset-Views I've added the standard-user-fields with:

[wpv-user field='user_firstname']

and the custom-user-fields with:

[types usermeta='team-zitat'][/types]

In my screenshot you can see, that the strings are translated and marked as finished.

Thanks for your help!

April 28, 2017 at 2:23 pm #1264387

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

1. Retrieving the user meta.
Are you using the suggested code to read the meta information from the database?

get_the_author_meta( 'user_url', $user_id );

2. Could you also post the code that you use in your "views"? I would like to get some consultation from our 2nd tier supporters.

thank you.

April 28, 2017 at 4:42 pm #1264507

Diana

1. No, I'm not using this code, because I'm not working with my own php-page-templates. Instead I'm working with Toolset Layouts and Views. And the shortcode
[wpv-user field='user_firstname'] places the standard-user-fields and
[types usermeta='team-zitat'][/types] places my custom-user-fields
in my template.

2. Here the loop-code of one of my Toolset-Views-Templates:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<wpv-loop>
    <div id="[wpv-user field='user_firstname']" class="person">
      <div class="visitbild">
        [types usermeta="portraet-bild"][/types]
      </div>
      <div class="visitdaten">
        <h4>[wpv-user field="user_firstname"] <b>[wpv-user field="user_lastname"]</b> <span>[types usermeta="team-titel"][/types]</span></h4>
        <p>[types usermeta="team-pos"][/types]</p>
        <div class="icons">
          <script type="text/javascript">javascript:contactteam('[wpv-user field="user_firstname"].[wpv-user field="user_lastname"]','next-pm.at');</script>
          <a href="<em><u>hidden link</u></em> field='user_firstname'][wpv-user field='user_lastname'].vcf" rel="external" alt="vCard zum Download">
            <div class="vcard"></div>
          </a>
        </div>
        <h5>[types usermeta="team-aufgaben"][/types]</h5>
        <p>[types usermeta="team-ausbildung"][/types]</p>
      </div>
      <div class="no-mobile visitbeschr">[wpv-noautop][wpv-user field="description"][/wpv-noautop]</div>
    </div>
	</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
[wpv-layout-end]

But the View works, so I don't think it's in this code. I also tried to add other content in the same View (for instance another Content-Template) and this shows up with the translated content. And because even the standard-user-fields aren't in English I think, there is more to do for getting the translated user-fields to work.

April 28, 2017 at 4:47 pm #1264511

Diana

If I have to place the above code to get this working, where should I do that?
Is there a Toolset- oder WPML-shortcode for that, so that I can place it in my View?

April 28, 2017 at 4:53 pm #1264516

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

I´m consulting with a colleague, please be patient - they may have already left for the weekend. = (

May 1, 2017 at 5:10 pm #1265622

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Hello.

Can you please provide access to your system. I think I will need to hand this over to someone more experienced with Toolset programming.

Thank you.

May 3, 2017 at 7:21 am #1266840

Diana

I'm developing on localhost and don't have an online-account yet for this project. May I give you a backup of my site? I'm working with UpdraftPlus and could provide you a clone of my development. It's about 350 MB at the moment ...

May 3, 2017 at 4:31 pm #1267406

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

1. System Snapshot
We actually have our support workflow built around the Duplicator package. Could you please use this instead?

The plugin is free and is easy to use. Here is an instructional video.
hidden link

2. String domain
We have noticed that our latest release introduced a bug that places strings from shortcodes into a "new" domain. This results in the strings not being translated. I am wondering if this coud be related to your issue.

2.1 Can you check if the user fields are enabled for translation in WPML String Translation and maybe try re-saving them?
2.2 Also, check their values – are they marked as “Translation is complete” ?

3. Private area
I am opening the private area for your to include a downloadable link of your site snapshot. Please use a file sharing service like Dropbox or Fileshare (or similar).

Thanks!

May 4, 2017 at 6:33 pm #1268555

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Hello again.

Thanks for doing this. I´ve been doing some research on the "other side of the house" and I found this ticket:

https://toolset.com/forums/topic/wpml-cant-translate-added-user-fields-content/

The date is Sept 2016 and I fear that this may imply that WPML cannot yet be used to translate these fields "as is".

I am double-checking this with our 2nd tier support as well as if there is a documented workaround. But I thought I´d raise this flag for your consideration. You might also ask on the Toolset forum for their inputs. (never hurts).

May 5, 2017 at 10:00 am #1269035

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Hello.

Thanks for your ongoing patience. I have escalated this issue to our 2nd tier support who will be able to help you get a definitive answer and hopefully a workaround.

Kind regards.

May 9, 2017 at 11:05 am #1271609

Diana

Hi Yvette! I searched on the Toolset-Forum and I checked out the link you gave me. You are right, the post is from Sep 16, but since then WPML and Toolset changed a few things. Now it is possible to translate the strings by adding the user-role in the string-translation-settings-page. They all appear in the domain "authors" (they didn't when the sep16-post was written).

So now it should be possible to implement the translated content in my Views. There should be a shortcode for that. Otherwise the setting in WPML to add a role for translation, wouldn't make sense. Would it?

May 9, 2017 at 2:01 pm #1271835

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+01:00)

Hello again.

Every WP default meta is translatable via ST if you go to ST > bottom right > activate translation for this roles...
So, custom meta should definitely be localized...and logically this would include meta information added via Types.

HOWEVER....

I have confirmation from the development team that this is not yet a supported feature.

You are right - it makes no sense imho.

I´ve added your ticket to the growing list of votes that this support be added. It´s the most I can do for now.

To return to your original quest, that would suggest that the only way to get these fields would be via

get_the_author_meta( 'user_url', $user_i

Your thoughts?

May 9, 2017 at 4:30 pm #1271987

Diana

Hi again!
Are you aware, that the translated WP-default-user-meta doesn't show off in the translated page as well? I tried it out with different default-user-meta-fields. Just for to test the behaviour I filled in different names for the German and the English version. But only the German names appeared ...

So that isn't a supported feature as well for the WP-default-user-fields? Or in which way do I have to include the fields in my Views. Which shortcode does the trick for these fields?