Reputation: 1057
I have a 2 websites, lets say SITE1 & SITE2
both running woo-commerce.
SITE1 receives orders, for every completed order on SITE1 i have to send an initiation to SITE2 with order information.
I created an webhook on SITE1 that posts information on SITE2 on every order creation
This above URL on SITE2 is a simple PHP file that accepts whatever that is posted to the URL.
But anything posted to that URL gets a 403 Forbidden by default.
How to create an URL that accepts woocommerce webhook post request that trigger a function?
Is there any inbuilt function for that ?
Upvotes: 1
Views: 2452
Reputation: 627
Try creating a plugin like this...or adding to your functions in your theme:
// make a function that loads before anything on wordpress loads
add_action('init','webhook_super_star');
// in the function look for a unique server related URI
// I personally like to check against a GET variable
function webhook_super_star() {
if( $_SERVER['REQUEST_URI'] == '/webhook' ||
$_SERVER['REQUEST_URI'] == '/webhook/') {
//Do some cool stuff
}
}
That's my guess with the information provided.
Have a nice day.
Upvotes: 2