WPML

问题概述

如果您的用户具有“自定义角色”,例如基于“编辑”角色的“商店管理员”,他们将无法编辑现有的翻译。

临时解决方法

此问题已在 WPML 4.6.9 中修复。 更新即可在您的站点上解决此问题,因此只有在您还无法更新时,才需要此临时解决方法。

1. 在 wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/wp/classes/User.php 的第 217 行,将方法 – \WPML\LIB\WP\User::isEditor 更改为:

public static function isEditor(WP_User $user = null) {
$capability = "editor";
$capability = apply_filters('wpml_editor_capability', $capability );
return self::hasCap( $capability, $user );
}

2. 在主题 functions.php 中添加以下代码:

add_filter('wpml_editor_capability', 'my_editor');
function my_editor(){
    $user = wp_get_current_user();
    if (in_array('second_custom_role', (array)$user->roles, true)){
        return 'second_custom_role';
    }
}

将 second_custom_role 部分更改为您的自定义角色名称,在本例中为 shop_manager。

所有已知问题

仍然遇到此问题?

如果更新无法解决问题,请提出支持问题,我们将与您一起排查。