Skip to content Skip to sidebar

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

Problem:
After upgrading WPML from version 4.6.3 to 4.6.11, the function has_user_rights_to_translate($trid, $lang) within class-wpml-tm-translation-status-display.php incorrectly denies editing rights to users with custom Editor roles. This issue arises because WPML checks for editor status based on a predefined set of capabilities, which does not accommodate custom modifications to Editor capabilities.
Solution:
We acknowledge the issue with the capacity-based access control introduced in the recent updates. Currently, we are considering implementing a specific custom role to handle various types of role and capability customizations. While we do not have an estimated time for this update, a temporary workaround involves modifying the User.php file. You can comment out the capabilities that your custom Editor roles do not have. This change will allow isEditor to return true, granting the necessary access rights.

Please note that this solution might be outdated or not applicable to your specific case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the issue persists, please open a new support ticket.

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.

Tagged: 

This topic contains 6 replies, has 2 voices.

Last updated by Nicolas V. 1 year, 10 months ago.

Assisted by: Nicolas V..

Author Posts
June 19, 2024 at 3:13 pm #15756764

charlesD-31

Background of the issue:
I am trying to edit translations on the site. After updating WPML, I encountered an issue. I referred to the solution at https://wpml.org/forums/topic/you-can-only-edit-translations-assigned-to-you-2/ and tried adding the capability wpml_manage_translation_management.

Symptoms:
You can only edit translations assigned to you.

Questions:
Why am I getting the error 'You can only edit translations assigned to you' after updating WPML?
Why does the solution at https://wpml.org/forums/topic/you-can-only-edit-translations-assigned-to-you-2/ not work for my case?

June 19, 2024 at 4:50 pm #15757693

Nicolas V.
WPML Supporter since 12/2021

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

As mentioned earlier, here are a few things to try to identify the root cause of the issue:
1. On your staging copy try a minimal environment:
- Disable any additional plugin that is not related to WPML and its add-ons and switch to a default theme like 2020.
- If the issue disappears please start reactivating the plugins one by one, or activate them in small groups. This way you can verify at which point the issue appears again and identify the plugin that is causing the issue.

2. If you think that the issue is related to a specific plugin, you can upload it to the sandbox site I shared and try to reproduce. Please don't install any other plugins that are not necessary to reproduce the issue.
URL: hidden link

July 2, 2024 at 1:05 pm #15875488

charlesD-31

Hello,

I have currently reproduced on my development environment that the issue occurs when updating the WPML Multilingual CMS plugin from 4.6.3 to 4.6.11.

I am collecting more information.

In the meantime, the sandbox has expired. Is there a way to restore it please so we don't lose our existing test cases?

Thanks
Reuben

July 2, 2024 at 1:41 pm #15875927

charlesD-31

Hello,

I have identified the problem. As mentioned earlier, the issue began after upgrading from version 4.6.3 to 4.6.11.

The problem lies in the function has_user_rights_to_translate($trid, $lang) within class-wpml-tm-translation-status-display.php. This function should permit editing if User::isAdministrator($user) || User::isEditor($user).

The user in question is not an Administrator but is definitely an Editor. However, isEditor is returning false.

It appears that WPML is checking if the user is an Editor not by their actual roles, but by a minimum set of capabilities defined in User.php:

public static function isEditor( \WP_User $user = null ) {
foreach ( static::ROLE_EDITOR_MINIMUM_CAPS as $cap ) {
if ( ! self::hasCap( $cap, $user ) ) {
return false;
}
}
return true;
}

The constant ROLE_EDITOR_MINIMUM_CAPS is defined as:

const ROLE_EDITOR_MINIMUM_CAPS = [
self::CAP_EDIT_OTHERS_POSTS,
self::CAP_PUBLISH_PAGES,
self::CAP_PUBLISH_POSTS,
self::CAP_EDIT_PAGES,
self::CAP_EDIT_POSTS,
];

Our Editors do not satisfy these capabilities. They have always their capabilities modified that allow them to edit a CPT rather than a regular Post. It also allows them to edit other users' post types of this CPT. Also, we do not permit Editors to modify Pages.

I confirm that has_user_rights_to_translate was introduced after version 4.6.3. I have downloaded the code for 4.6.3 and this check was not there.

I kindly request you to reconsider the logic of checking if User::isEditor based on ROLE_EDITOR_MINIMUM_CAPS.

There may be cases where an Editor needs to have some capabilities removed for security reasons, which WPML now requires as "minimum" to consider them an Editor.

In your changelog for Version 4.6.7 I see:

"Enhanced the capabilities for editors with correct language pairs so they can access translation that is translated by a different translator."

This change may have been the source of the problem.

Thank you.

Reuben

July 2, 2024 at 6:56 pm #15877700

Nicolas V.
WPML Supporter since 12/2021

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

Thanks for the detailed report and reporting this.
To give you some background: We had quite a few reports with clients creating custom roles with similar plugin than the one you're using. So the "workaround" was to based it on "capabilities" instead of roles.

However, as a side effect, default roles with custom capabilities like yours might encounter that issue now.

It's already being discussed to have a specific custom role to edit the translation - to be able to handle of types of customizations (roles/capabilities). Unfortunately I don't have an ETA to share at the moment. I added your ticket to give more weight to this request.

For the time being, the workaround would be to comment out capabilities your editors don't have (from the piece of code your shared in User.php) that way isEditor returns true.

July 3, 2024 at 2:55 pm #15885468

charlesD-31

Dear Nicolas,

Thank you for the update.

What would be the best way for us to remain updated on this update?

Reuben

July 3, 2024 at 6:10 pm #15886384

Nicolas V.
WPML Supporter since 12/2021

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hi Reuben,

- On your end, following the changelog will help you detect any changes related to this issue: https://wpml.org/download/wpml-multilingual-cms/?section=changelog

- On our end, I have added your ticket to the internal dev ticket, so if there is any update or ETA, I will be notified and will contact you in this very ticket.

For now, I will mark this ticket as "Fixed in next release" even if I don't have the ETA yet. And don't worry if the ticket gets automatically closed for inactivity, I can still reply in it or reactive it if necessary.

Thanks for reporting this and for your comprehension.
Nico