Using WP Zapier Custom Webhook
WP Zapier version 2.0+ includes custom webhooks for receiving data, this allows developers to use our webhook feature and leverage our functionality with custom code snippets to open up integrations even more. Giving developers full control when using this webhook action for receiving data from Zapier.
Working With WP Zapier Custom Webhook
The ‘custom’ webhook action for WP Zapier is aimed for developers and will allow developer’s to write custom code when receiving data and even integrating with a plugin that may not support receiving data natively like WP Zapier does. For example, you can pass through any data you wish to your WordPress site and then handle the data accordingly.
Here is an example of using the custom webhook action in WP Zapier, to update user meta of a user (via ID):
Time needed: 30 minutes.
- Setup your Zap inside Zapier, or alternative service to collect data from a point.
For example, you can use a Google Sheet to post data to Zapier or when a user signs up for a newsletter subscription etc. Be sure to map your data as you would with any other action when receiving data from WordPress.
In this example, we will be passing 3 key-value pairs for our custom webhook: user_id, name and the action (type of WP Zapier trigger).
- Write/Add a Custom Function to your WordPress site.
If you aren’t familiar with how to customize WordPress, be sure to see our guide here.
We are now going to add a custom function to update user meta from data we received in the above step. (This is a basic example and may be extended to handle more robust requests such as creating an order in an Ecommerce plugin, giving user’s a coupon code and more!
The above example shows how to use the custom webhook function for WP Zapier, when the other actions aren’t needed. This will be used when developer’s don’t need to run code to update a user or to create a user but something outside of the WordPress user scope. The code above does add user meta to specific users, but this is only for explanation for what this hook can be used for. There will be more examples coming in the future around this on what you can do.
Related link: Add User’s to MailPoet List via Zapier.