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.

Our next available supporter will start replying to tickets in about 2.96 hours from now. Thank you for your understanding.

This topic contains 2 replies, has 2 voices.

Last updated by Itamar 2 years, 8 months ago.

Assigned support staff: Itamar.

Author Posts
October 11, 2017 at 9:25 am #1397817

Andrea

How can I programmatically add wp_user to translators?

October 11, 2017 at 8:53 pm #1398629

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hello, Andrea.

Thank you for contacting the WPML support forum.

I'm not sure that this is possible, but I'm going to ask our second tier supporter about it and get back to you here when I have an answer.

Thank you for your patience,
Itamar.

October 13, 2017 at 8:48 am #1399993

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi, Andrea.

I've got an answer from our second tier supporter.
This kind of modification that you want to achieve is a custom work and is out of the scope of this forum.
Nevertheless, we can point out the file where WPML adds translators.
It is in this location:
\sitepress-multilingual-cms\inc\translation-management\translation-management.class.php

function add_translator( $user_id, $language_pairs ) {
global $wpdb;

$user = new WP_User( $user_id );
$user->add_cap( 'translate' );

$um = get_user_meta( $user_id, $wpdb->prefix . 'language_pairs', true );
if ( ! empty( $um ) ) {
foreach ( $um as $fr => $to ) {
if ( isset( $language_pairs[ $fr ] ) ) {
$language_pairs[ $fr ] = array_merge( $language_pairs[ $fr ], $to );
}
}
}

update_user_meta( $user_id, $wpdb->prefix . 'language_pairs', $language_pairs );
$this->clear_cache();
}

So basically there are two things that you can do there:
1. Add a custom cap to user capabilities “translate.”
2. Update meta key “language_pairs” “from languages” to “to languages”.

I hope that this information is helpful for you.

If you need more help with this issue, I would suggest you consider contacting one of our certified partners from this link:
http://wpml.org/documentation/support/wpml-contractors/

Before doing so, please have a look also here:
http://wpml.org/documentation/support/wpml-contractors/guidelines-for-people-looking-for-consulting-help/

You will get the custom assistance you need to get on with your project.

Thanks,
Itamar.

The topic ‘[Closed] How can I programmatically add wp_user to translators?’ is closed to new replies.