Forked from mariovalney/cf7-to-webhook-air-table.php
Last active
December 7, 2020 23:38
-
-
Save farik92/3ef236d3e255d69e06e53e3072c8fa39 to your computer and use it in GitHub Desktop.
Send webhook to Airtable API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * | |
| * Plugin Name: CF7 to Webhook - Airtable | |
| * Description: Send webhook to Airtable API | |
| * Version: 1.0.0 | |
| * Author: Mário Valney | |
| * Author URI: https://mariovalney.com | |
| * Text Domain: cf7-to-webhook-air-table | |
| */ | |
| add_filter( 'ctz_post_request_args', 'ctwat_post_request_args' ); | |
| /** | |
| * Change the post request to send data to Airtable API | |
| * | |
| * @see https://youtu.be/snl_OQbm3UI?t=631 | |
| * @see https://developer.wordpress.org/reference/functions/wp_remote_post/ | |
| * | |
| * @param $args array | |
| * @return $args | |
| */ | |
| function ctwat_post_request_args( $args ) { | |
| $args['headers']['Authorization'] = 'Bearer YOUR_TOKEN_HERE'; | |
| $body = json_decode( $args['body'] ); | |
| $body = array( | |
| 'records' => array( | |
| array( | |
| 'fields' => $body, | |
| ), | |
| ), | |
| ); | |
| $args['body'] = json_encode( $body ); | |
| return $args; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment