Created
July 10, 2021 17:41
-
-
Save bahiirwa/7cd116c39e057c92a077a2dd9130e3d0 to your computer and use it in GitHub Desktop.
Collect Gravity forms to send to External API
This file contains 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: Trap Gravity Forms | |
* Plugin URI: https://github.com/yttechiepress/trap-gravity | |
* Author: TechiePress | |
* Author URI: https://github.com/yttechiepress/trap-gravity | |
* Description: Collect Gravity forms to Webhook | |
* Version: 0.1.0 | |
* License: GPL2 | |
* License URL: http://www.gnu.org/licenses/gpl-2.0.txt | |
* text-domain: trap-gravity | |
*/ | |
defined( 'ABSPATH' ) or die( 'No entry' ); | |
add_action( 'gform_after_submission_2', 'techiepress_after_submission', 10, 2 ); | |
function techiepress_after_submission( $entry, $form ) { | |
// error_log( print_r( $entry, true ) ); | |
if ( $entry['form_id'] == 2 ) { | |
$info = [ | |
'name' => $entry[1], | |
'number' => $entry[3], | |
'email' => $entry[2], | |
]; | |
$url = 'https://hook.integromat.com/g7oli6aslhs210jmbt8hpyibb9dsndh4'; | |
$args = [ | |
'method' => 'POST', | |
'body' => $info, | |
]; | |
wp_remote_post( $url, $args ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment