Using the Translator Accounts Add-on you can create or allow existing users to translate the site without admin rights.
The translators will be able to translate the website (directly from the front-end) without having to work with the WordPress back-end, site builders or meta boxes.
Install and activate a premium version of TranslatePress (Business or Developer). Once installed, go to Settings → TranslatePress in your WordPress dashboard, and then navigate to the Addons tab.
Scroll down to the Translator Accounts Add-on and Activate it here.
Create a new user with the Translator role: WordPress → Users → Add New.
Allow existing users to translate the website: WordPress → Users → Edit User → TranslatePress Settings (or by changing their current role to the Translator role).
By default, the add-on grants users access to all languages set on your site. However, it does not offer the option to restrict users to editing only a few selected languages.
The following code allows you to limit the available languages for a specific user. For example, it can be used to restrict User1 to editing only Romanian and Italian.
/*
* Limit the actual available languages for a particular user.
*
*/
add_filter( 'option_trp_settings', 'filter_trp_settings' );
function filter_trp_settings( $settings ) {
// Define the languages you want to exclude
$excluded_languages = array( 'ro_RO', 'it_IT' ); // Example languages to exclude
$is_editor = (isset($_GET['trp-edit-translation'])) ? $_GET['trp-edit-translation'] : false;
$current_user = wp_get_current_user();
if ( $is_editor && $current_user && $current_user->user_login === 'user' && isset( $settings['translation-languages'] ) && is_array( $settings['translation-languages'] ) ) {
// Remove excluded languages from 'url-slugs'
if ( isset( $settings['url-slugs'] ) && is_array( $settings['url-slugs'] ) ) {
foreach ( $excluded_languages as $lang ) {
unset( $settings['url-slugs'][ $lang ] );
}
}
// Remove excluded languages from 'translation-languages'
if ( isset( $settings['translation-languages'] ) && is_array( $settings['translation-languages'] ) ) {
$settings['translation-languages'] = array_values(array_diff( $settings['translation-languages'], $excluded_languages ));
}
// Remove excluded languages from 'publish-languages'
if ( isset( $settings['publish-languages'] ) && is_array( $settings['publish-languages'] ) ) {
$settings['publish-languages'] = array_values(array_diff( $settings['publish-languages'], $excluded_languages ));
}
}
return $settings;
}
How to Use:
$excluded_languages
array with the language codes you wish to restrict.'user1'
with the username of the user you want to limit to specific languages.Get Translator Accounts Add-on