Fixed permissions error messages
This commit is contained in:
parent
bb029747b7
commit
8df7723895
|
@ -64,7 +64,7 @@ abstract class WC_REST_Posts_Controller extends WP_REST_Controller {
|
||||||
*/
|
*/
|
||||||
public function create_item_permissions_check( $request ) {
|
public function create_item_permissions_check( $request ) {
|
||||||
if ( ! wc_rest_check_post_permissions( $this->post_type, 'create' ) ) {
|
if ( ! wc_rest_check_post_permissions( $this->post_type, 'create' ) ) {
|
||||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -96,7 +96,7 @@ abstract class WC_REST_Posts_Controller extends WP_REST_Controller {
|
||||||
$post = get_post( $request['id'] );
|
$post = get_post( $request['id'] );
|
||||||
|
|
||||||
if ( $post && ! wc_rest_check_post_permissions( $this->post_type, 'edit', $post->ID ) ) {
|
if ( $post && ! wc_rest_check_post_permissions( $this->post_type, 'edit', $post->ID ) ) {
|
||||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -128,7 +128,7 @@ class WC_REST_Customers_Controller extends WP_REST_Controller {
|
||||||
*/
|
*/
|
||||||
public function create_item_permissions_check( $request ) {
|
public function create_item_permissions_check( $request ) {
|
||||||
if ( ! wc_rest_check_user_permissions( 'create' ) ) {
|
if ( ! wc_rest_check_user_permissions( 'create' ) ) {
|
||||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -160,7 +160,7 @@ class WC_REST_Customers_Controller extends WP_REST_Controller {
|
||||||
$id = (int) $request['id'];
|
$id = (int) $request['id'];
|
||||||
|
|
||||||
if ( ! wc_rest_check_user_permissions( 'edit', $id ) ) {
|
if ( ! wc_rest_check_user_permissions( 'edit', $id ) ) {
|
||||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -106,7 +106,7 @@ class WC_REST_Order_Notes_Controller extends WP_REST_Controller {
|
||||||
*/
|
*/
|
||||||
public function create_item_permissions_check( $request ) {
|
public function create_item_permissions_check( $request ) {
|
||||||
if ( ! wc_rest_check_post_permissions( 'shop_order', 'create' ) ) {
|
if ( ! wc_rest_check_post_permissions( 'shop_order', 'create' ) ) {
|
||||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -94,7 +94,7 @@ class WC_REST_Tax_Classes_Controller extends WP_REST_Controller {
|
||||||
*/
|
*/
|
||||||
public function create_item_permissions_check( $request ) {
|
public function create_item_permissions_check( $request ) {
|
||||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'create' ) ) {
|
if ( ! wc_rest_check_manager_permissions( 'settings', 'create' ) ) {
|
||||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -108,7 +108,7 @@ class WC_REST_Taxes_Controller extends WP_REST_Controller {
|
||||||
*/
|
*/
|
||||||
public function create_item_permissions_check( $request ) {
|
public function create_item_permissions_check( $request ) {
|
||||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'create' ) ) {
|
if ( ! wc_rest_check_manager_permissions( 'settings', 'create' ) ) {
|
||||||
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -136,7 +136,7 @@ class WC_REST_Taxes_Controller extends WP_REST_Controller {
|
||||||
*/
|
*/
|
||||||
public function update_item_permissions_check( $request ) {
|
public function update_item_permissions_check( $request ) {
|
||||||
if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) {
|
if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) {
|
||||||
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue