php - Disable woocomerce api authentication? -


the woocomerce api takes oauth1.0 http requests , basic http authentication https requests. query simple. how remove authentication? did digging , found there class in woocommerce plugin constructor

public function __construct() {          // disable authentication, hook filter @ later priority , return valid wp_user         add_filter( 'woocommerce_api_check_authentication', array( $this, 'authenticate' ), 0 );     } 

my job remove authentication part. here saying hook filter @ later priority. how , how return valid wp_user?

create own plugin , place following code:

function wc_authenticate_alter(){     //return wp_get_current_user();     if( 'get' ==  wc()->api->server->method ){         return new wp_user( 1 );     } else {         throw new exception( __( 'you dont have permission', 'woocommerce' ), 401 );     } }  add_filter( 'woocommerce_api_check_authentication', 'wc_authenticate_alter', 1 ); 

this bypass woocommerce api authentication. use own risk.

(you can add in theme's functions.php instead of own plugin. not tested.)


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -