jasonknight / woocommerce-json-api

A simple, Abstract JSON API for Wordpress' Awesome Plugin: WooCommerce
58 stars 21 forks source link

Cannot work while logged into Wordpress. Why? #23

Closed donnguyen closed 11 years ago

donnguyen commented 11 years ago

Hi, Could you please explain more why this plugin cannot work while user logged into WP? I really don't understand why. Because I'm in a project that requires adding new product (also adding that one to cart) while user logged or hasn't logged yet. But for now, while user logged, we just get fail. As author of this plugin could you explain more and any chances we can make this plugin work in this case? Thank you very much! You are doing great job!

Don

jasonknight commented 11 years ago

The API logs the API user in. Which would mess up the current session for the actual user. This is essentially what was happening to some users of the API.

The restriction could theoretically be removed. i.e. if the current user is logged in, it could just do things as that user...However, the API was designed for 3rd party apps to connect to Woo... Like from another server. Not on the same server/same page.

To remove the restriction, just comment out the 2 returns in template_redirect, and then in class-wc-json-api we need to modify logUserIn.

jasonknight commented 11 years ago

I have noticed a growing desire for people to use the api for some kinds of widgets on the page, as it avoids having to deal with messy WP Ajax and plugin stuff.

I am very open to removing this restriction.