Programmatically Trigger Gravity Forms Notification

Until it makes its way to the new Gravity Forms API, you can programmatically send a specific Gravity Forms notification using the GFCommon::send_notification function which receives the notification ID, the form object, and the lead object.

If you need to send multiple notifications, you can use GFCommon::send_notifications which receives an array of IDs.

Here’s how I use send all of the notifications for a specific event that occurs:

<?php
function send_notification ( $event, $form, $lead ) {
$notifications = GFCommon::get_notifications_to_send( $event, $form, $lead );
$notifications_to_send = array();
//running through filters that disable form submission notifications
foreach ( $notifications as $notification ) {
if ( apply_filters( "gform_disable_notification_{$form['id']}", apply_filters( 'gform_disable_notification', false, $notification, $form, $lead ), $notification, $form, $lead ) ) {
//skip notifications if it has been disabled by a hook
continue;
}
$notifications_to_send[] = $notification['id'];
}
GFCommon::send_notifications( $notifications_to_send, $form, $lead, true, $event );
}
?>


Questions? Email Me