Skip Navigation

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

Problem:
We are trying to set up a user role for translators on our site that gives them the permissions to edit and translate the content, but not to access plugins and theme options.

Solution:
Just add this code to the functions.php file:

add_filter('wpml_user_can_translate', function ($user_can_translate, $user){
    if (in_array('editor', (array) $user->roles, true) && current_user_can('translate')) {
        return true;
    }
     
    return $user_can_translate;
}, 10, 2);

67% of people find this useful.

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

Last updated by Radu 3 years, 3 months ago.

Assisted by: Radu.

Author Posts
January 3, 2022 at 10:31 am #10276067

Radu

Hey Rachel,

Can you have a look at my previous reply here, please?
https://wpml.org/forums/topic/editor-role-permissions/page/2/#post-10276055

Thanks,
Radu

January 8, 2022 at 5:11 am #10309497

rachelA-6

Thanks Radu. The site migration to Cloudways is now complete.

January 10, 2022 at 2:51 pm #10319797

Radu

Hey Rachel,

Thank you for taking care of the site migration. I had another look at the settings thinking that I might be able to find a change to make things work, but I had no luck with that.

In this case, I asked my colleague to have another look and see what am I missing. I'll keep you posted on this one.

Thanks,
Radu

January 12, 2022 at 10:02 am #10333991

rachelA-6

Thanks Radu.

January 12, 2022 at 4:38 pm #10337851

Radu

No problem 🙂

I am currently checking this one with one of my colleagues and I'll come with another message with what we found.

Thanks,
Radu

January 15, 2022 at 12:52 pm #10357215

Radu

Hey Rachel,

My colleague checked the migrated website but couldn't find any change to make things work. In this case, I had to escalate this to the 2nd tier to have a closer look at the issue. I'll keep you posted about the progress we're making on this one (this ticket is linked to the internal thread).

Thanks,
Radu

January 17, 2022 at 2:02 am #10362333

rachelA-6

Thanks for the update Radu.

January 17, 2022 at 6:13 am #10363037

Radu

Anytime 🙂

I'll keep you posted about this.

Regards,
Radu

January 17, 2022 at 1:06 pm #10366415

Radu

Hey Rachel,

Can you try again to edit the translations using the editor account, please?

I just added this code to the functions.php file:

add_filter('wpml_user_can_translate', function ($user_can_translate, $user){
	if (in_array('editor', (array) $user->roles, true) && current_user_can('translate')) {
		return true;
	}
	
	return $user_can_translate;
}, 10, 2);

which enables this option. By default, the WPML behavior is to have only the admin or the original translator be able to edit the translations. However, this additional code will let the editor edit the translations as well.

Thanks,
Radu