Please make sure to update to WPML 4.3.4 before reporting any issue

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 topic contains 2 replies, has 2 voices.

Last updated by Itamar 2 years, 1 month 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+02: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+02: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.