From 20efcfb8042f725e57a6b8c868d5496549302d3d Mon Sep 17 00:00:00 2001 From: Nima Date: Tue, 3 Jan 2023 14:05:27 +0000 Subject: [PATCH] Change API access permission --- plugins/woocommerce/src/Admin/API/MarketingCampaigns.php | 4 ++-- plugins/woocommerce/src/Admin/API/MarketingChannels.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/woocommerce/src/Admin/API/MarketingCampaigns.php b/plugins/woocommerce/src/Admin/API/MarketingCampaigns.php index e59ede8740d..8316d9ef11f 100644 --- a/plugins/woocommerce/src/Admin/API/MarketingCampaigns.php +++ b/plugins/woocommerce/src/Admin/API/MarketingCampaigns.php @@ -67,8 +67,8 @@ class MarketingCampaigns extends WC_REST_Controller { * @return WP_Error|boolean */ public function get_items_permissions_check( $request ) { - if ( ! current_user_can( 'install_plugins' ) ) { - return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view marketing campaigns.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); } return true; diff --git a/plugins/woocommerce/src/Admin/API/MarketingChannels.php b/plugins/woocommerce/src/Admin/API/MarketingChannels.php index 6772cfbcc42..bb22cd01c74 100644 --- a/plugins/woocommerce/src/Admin/API/MarketingChannels.php +++ b/plugins/woocommerce/src/Admin/API/MarketingChannels.php @@ -65,8 +65,8 @@ class MarketingChannels extends WC_REST_Controller { * @return WP_Error|boolean */ public function get_items_permissions_check( $request ) { - if ( ! current_user_can( 'install_plugins' ) ) { - return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view marketing channels.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); } return true;