• We are using WooCommerce with a plugin (Shipmondo) to help with shipping. This plugin has it’s own control panel, which connects with the REST API in WordPress, to process orders.

    Ever since we installed User Role Editor, we get this error from the shipping control panel , when we try to complete an order: {“code”:”woocommerce_rest_cannot_edit”,”message”:”Sorry, you are not allowed to edit this resource.”,”data”:{“status”:401}}

    My first guess was the problem was caused by User Role Editor. So I tried to disable the plugin, but the problem still wasn’t fixed.

    The shipping plugin was working fine before I installed URE. So do you know if URE has any effect on the REST API?

    Kind Regards
    Morten

    • This topic was modified 3 years, 6 months ago by Mortenz.
Viewing 1 replies (of 1 total)
  • Plugin Author Vladimir Garagulya

    (@shinephp)

    Hi Morten,

    URE does not change itself permissions required by WordPress or WooCommerce Rest API.

    Check if your user can permission checked by WooCommerce REST API. For example, WooCommerce file class-wc-rest-shipping-zones-controller-base.php checks user permissions via function below, and requires ‘manage_woocommerce’ for ‘shipping_methods’ $object argument value:

    
    /**
     * Check manager permissions on REST API.
     *
     * @since 2.6.0
     * @param string $object  Object.
     * @param string $context Request context.
     * @return bool
     */
    function wc_rest_check_manager_permissions( $object, $context = 'read' ) {
    	$objects = array(
    		'reports'          => 'view_woocommerce_reports',
    		'settings'         => 'manage_woocommerce',
    		'system_status'    => 'manage_woocommerce',
    		'attributes'       => 'manage_product_terms',
    		'shipping_methods' => 'manage_woocommerce',
    		'payment_gateways' => 'manage_woocommerce',
    		'webhooks'         => 'manage_woocommerce',
    	);
    
    	$permission = current_user_can( $objects[ $object ] );
    
    	return apply_filters( 'woocommerce_rest_check_permissions', $permission, $context, 0, $object );
    }
    
Viewing 1 replies (of 1 total)
  • The topic ‘UserRoleEditor affecting REST API?’ is closed to new replies.