PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, February 5, 2022

[FIXED] Disable WooCommerce API authentication for Custom endpoint

 February 05, 2022     restful-authentication, woocommerce-rest-api, wordpress     No comments   

Issue

I have created a custom WooCommerce API endpoint (in a custom WP plugin) for that creates a new order in WooCommerce. I usually use HTTPS and basic auth with consumer key and consumer secret.

This customer API was designed to be accessed by another platform that does not have the ability to enter consumer key and secret in request header. So I would like to disable WooCommerce authentication for this plugin only. I will be authenticating using a field in the original request by comparing a key.

Does anyone know how to do this?


Solution

I found the solution:

// To disable authentication, hook into this filter at a later priority and return a valid WP_User

    add_filter( 'woocommerce_api_check_authentication', array( $this, 'authenticate' ), 0 );


Answered By - Amjad
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing