In WordPress, user accounts have fields for information like the name, nickname, biography, and more. WPML allows you to translate this user meta information.
Before starting, make sure you have the String Translation add-on installed and activated. Then, go to WPML → String Translation to enable user meta translation. Scroll down to the More options section, click edit, and choose the user roles you would like to make translatable.
Enabling user meta translation
To translate the user metadata:
Return to the top of the WPML → String Translation page, select In Domain: Authors, and click Search. The list should now display the names of the fields available for translation, followed by a number. This number represents the ID of the user the string belongs to.
Click the plus icon for the user string and language you want to translate and enter the translation.
Displaying user strings available for translation
Certain fields, such as first name, last name, website, and bio will not be visible in your String Translation table until you modify them. Return to Users → Profile and make a small change to the fields, such as adding a space or word. Save your changes to add the strings to the String Translation table.
Translating Custom User Fields
By default, the only user fields you can translate are first_name, last_name, nickname, description, and display_name.
To make custom user fields translatable, you need to add a WPML filter to your theme’s functions.php file. We recommend using a child theme for this because otherwise, your changes will be overwritten the next time you update your theme.
In the following example, we make our custom user field “Position” translatable (we use the field’s slug):
To make more custom user fields translatable, you can repeat this same code as many times as needed. Just make sure to use the correct field slug for each field.
Displaying User Metadata Translations on the Front-end
You can use the following function to display translations of user fields on the front-end:
While there are other ways to get user meta, this is the only way to display translated user meta fields.
Manage Cookie Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.