Get started

This plugin extends the possibilities of WP Webhooks Pro by initializing a new functionality called Code Trigger. A Code Trigger is a piece of code (created via webhooks) that runs every time WordPress is called. 
This enables you to create a piece of code on your system that runs everytime someone interacts with your websites, calls an api or a webhook. 
You will be able to setup code that is always available, even when your webhook is not making any calls at the moment. To top that, you are also able to manage these Code Triggers via webhooks. 
Also, we added another security feature that checks your code for possible php errors before taking it live. This way, you won’t run into 500 errors anymore. 

How to use it

  1. Upload the zip file to your WordPress site (Plugins > Add New > Upload)
  2. Activate the plugin
  3. Go to Settings > WP Webhooks Pro -> Settings
  4. Scroll down and activate the specified action and click Save
  5. Go to Recieve Data and start implementing the webhook
  6. Go to the Code Triggers tab and check the currently installed Code Triggers

Now just copy the specified webhook you want to use for that (The link with the long API key at the end) and head over to your webhook handler.

In this example, we will demonstrate the functionality using Zapier.

On Zapier you can create a new Zap, setup a custom trigger and add a new action. For the action you can choose from the built-in apps the app Webhooks.

Now you are prompted to choose a Zapier Webhook. Choose POST or Custom Request and click “Save and continue” (In this example we cover POST)

On the next page, you need to include an URL. Please include there your webhook URL from your websites “Recieve Data” page.

For the Payload type, you can choose between Form, XML or JSON. You can also use plain text or html. Please see for more information.

In this example, we are going to use the Payload Type “Json“, as well as the webhook action “create_code_trigger”

After including the URL and checking the Payload Type, scroll down and set the following button to no: Unflatten 

Now you can scroll up again and place your actions into the Data fields.
As an action, you can choose create_code_trigger. For this action, it is required to define the “slug” field, as well as the “code” field. The slug is a unique identifier for the code block you want to register. The code field includes the PHP code you want to run within your trigger. Please include it without start and ending tag ( No <?php or ?> at the beginning or at the end ). For more details, check out the description of the webhook inside of WP Webhooks Pro plugin

Now you can click save and finish the setup! After you set up your Zap, don’t forget to activate it.

After the set up was complete, you will be able to create the code trigger on your website. As soon as it runs the first time, you will be able to see the piece of code that should run within your WordPress site under Settings -> WP Webhooks Pro -> Code Trigger

In case you want to deactivate a custom code trigger, you can call the code_trigger_status action. You will find more details about it within the defined action description.

It is also possible to delete a Code Trigger by using the following action: delete_code_trigger
You will find more details about it within the defined action description.

Updated on March 30, 2019

Was this article helpful?