あなたのテーマのfunctions.phpでこれを試してみてください
//mydomain.com/my-account/view-order/xxxx - ここでは、任意の順序番号
function my_customer_has_capability($allcaps, $caps, $args) {
if (isset($caps[0])) {
switch ($caps[0]) {
case 'view_order' :
$user_id = $args[1];
$order = wc_get_order($args[2]);
if ($order && $user_id == $order->user_id || my_get_current_user_role() == 'editor') {
$allcaps['view_order'] = true;
}
break;
}
}
return $allcaps;
}
add_filter('user_has_cap', 'my_customer_has_capability', 10, 3);
function my_get_current_user_role() {
$current_user = wp_get_current_user();
if (!($current_user instanceof WP_User))
return;
if(empty($current_user->roles[0]))
return false;
$role = ($current_user->roles[0]);
return (string)$role;
}
は、カスタムの役割を作成しましたか?あなたは 'read_shop_order'を許可するが、' edit_shop_order'を許可しないロールを定義することはおそらく可能です。 [このインストール機能](https://github.com/woocommerce/woocommerce/blob/70d46fe008fd722561855a76b6a605188569d231/includes/class-wc-install.php#L716)を参照してください。 – helgatheviking
これを試しますが、これ以上の提案は大歓迎です! –
これはWooCommerce固有の役割機能を示すWooCommerceソースコードへの単なるリンクです。おそらく 'shop_manager'ロールを複製し、編集機能を削除することができます。 – helgatheviking