I have a simple script that sends Slack messages, runs reports and does other things. I would like this script to run directly based after users purchase something on my site. I do NOT want to build this functionality using WordPress, my goal is to have loosely coupled systems.

ENTER WEBHOOKS.

Webhooks sound exactly like what I want. Something happens on WordPress and then it pings my reporting server.

WordPress advertises a webhooks feature at https://en.support.wordpress.com/webhooks/ it states this there is a WEBHOOKS option under SETTINGS in admin.

enter image description here

However, on my WordPress I do not have this menu option.

enter image description here

Is there something special I have to do to get this menu?

4 Answers
4

You are using self-hosted WordPress, which sometimes referred to as WordPress.org.

Calling remote hook is still a possibility there, but unless your e-commerce solution supports it, you may need to add a custom code.

  1. Option – find a plugin

There are some plugins which will post data to external URL when certain event happens, say, form is submitted. Those may be specific to your forms or may be somewhat generic (supporting different forms). Likely there is something for WooCommerce and other systems. Unfortunately can’t be more specific without knowing what you are using

  1. For purchases – your payment processor may have webhooks.

I use webhooks with Stripe, for example. Purchase is made through WP but as soon as it’s charged to credit card using Stripe, I get a callback from Stripe with all info. So, no need for posting it again from WordPress.

  1. Add custom code to do webhook for you

Pretty much every action in WordPress triggers some “action”, which can be caught by your plugin. Basically all you need to do is register and action and once it happens post to your external server.

More about actions: https://codex.wordpress.org/Plugin_API#Hooks:_Actions_and_Filters

Leave a Reply

Your email address will not be published. Required fields are marked *