2

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?

  • I believe that link is about sites hosted on Wordpress.com – hwl Jul 20 '17 at 18:37
3

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

  • Thank you for explaining. Is there a plugin that allows arbitrary wordpress actions to be specified? I can tell my vendor to make my custom plugin use actions. And that tool could turn actions into webhooks. – William Entriken Jul 26 '17 at 0:55
  • WordPress has available hooks that can be used to trigger arbitrary actions. One example is developer.wordpress.org/reference/hooks/…. When another website posts to your site through a URL that looks like example.com/wp-admin/admin-post.php?action=foobar, the foobar function that you define will be executed. – ajie Aug 8 at 17:38
1

Since a lot changed within the last years, I wanted to make an update on what's new in the WordPress webhook world (2019+).

The document you mentioned is provided by WordPress.com, which is a different service than the self-hosted websites via WordPress.org.

To archive that goal there are a couple of possibilities:

1. Use an already existing plugin

The easiest way would be to use a plugin that already offers webhooks. If you want to cover a specific use-case, it makes sense to search for a specific solution. For example, Woocommerce offers slack integration as a plugin: https://woocommerce.com/products/woocommerce-slack/

In case you want a global solution so that you can basically integrate everything, I recommend you WP Webhooks - They have a free version available and it works great out of the box. It allows you not only to send data from WordPress but also to receive data. You can also connect it easily in both ways with Zapier, automate.io and a lot of other services.

Another possible plugin would be Hookpress - It also offers you the possibility to send data from WordPress to any webhook. The only issue is that it is not maintained anymore and there are compatibility issues with PHP 7+

Another plugin would be WebSub/PubSubHubbub - It works great as well but has more specific use-cases.

2. Custom Code

In case nothing of the above suits your use-case, you can always start creating your own piece of code for it or hire a developer to do it for you. In case you want to do it by yourself, you should check out the following WordPress functions: wp_remote_post and wp_remote_get

If you want to hire a developer, I recommend you to ask on fiverr or Upwork or in case you want only expert developers Codeable

If you know something I don't know, feel free to reach out and I'll add it as well :)

0

When you are using a self-hosted website , follow the steps below :

  1. Login to your site admin dashboard yoursite.com/wp-admin

  2. Click on Settings , then click in writing settings yoursite.com/wp-admin/options-writing.php

  3. Scroll to you Update Services

  4. Add your endpoint urls

Thats all the steps .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.