Hello, I am new to building plugins, and I want to have a plugin that is universal for my installs. I have built a simple plugin that will generate email when webhook fails. I originally added the code to the function.php, but realized after update this code gets eliminated (noob). So I build plugin. can someone tell me how can I call the website URL to make this a universal plugin? and also how to send to admin email (please see caps areas). and maybe someone can add code here that will auto retry the webhooks?
The code doesn’t look right on here, download the file
Code:
<?php
/*
Plugin Name: Gravity Forms Webhook Fail Notifications
Plugin URI:
Description: Sends notification email to administrator when the webhook fails from gravity forms
Author: Myles
Version: 1.0.4
Author URI:
License: GPL2
*/
add_action( 'gform_webhooks_post_request', function ( $response, $feed, $entry, $form ) {
if ( is_wp_error( $response ) ) {
$to = 'NEED TO SEND TO ADMIN EMAIL HERE'; // Change this to your email address.
$subject = 'Webhook failed at NEED TO DISPLAY WEBSITE HERE';
$body = "Webhook for entry #$entry[id] form #$form[id] failed."; //IS THIS CORRECT TO CALL THE ENTRY ID AND THE FORM ID? I HAVE 20+ FORMS I NEED TO KNOW WHICH ONE FAILED
wp_mail( $to, $subject, $body );
}
}, 10, 4 );
?>