Change API access denied authorization code

This commit is contained in:
Nima 2023-01-03 11:27:31 +00:00
parent 4d6ef8ece3
commit 264c92a52f
3 changed files with 4 additions and 4 deletions

View File

@ -68,7 +68,7 @@ class MarketingCampaigns extends WC_REST_Controller {
*/
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' => 400 ) );
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view marketing campaigns.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
@ -192,7 +192,7 @@ class MarketingCampaigns extends WC_REST_Controller {
'readonly' => true,
],
'manage_url' => [
'description' => __( 'URL to the campaign management page', 'woocommerce' ),
'description' => __( 'URL to the campaign management page.', 'woocommerce' ),
'type' => 'string',
'context' => [ 'view' ],
'readonly' => true,

View File

@ -66,7 +66,7 @@ class MarketingChannels extends WC_REST_Controller {
*/
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' => 400 ) );
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view marketing channels.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;

View File

@ -74,7 +74,7 @@ class MarketingRecommendations extends WC_REST_Controller {
*/
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' => 400 ) );
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view marketing channels.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;