Skip to content

Instantly share code, notes, and snippets.

@naomicbush
Last active August 29, 2023 06:10
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save naomicbush/43f46dd16f1dbb1491c2 to your computer and use it in GitHub Desktop.
Save naomicbush/43f46dd16f1dbb1491c2 to your computer and use it in GitHub Desktop.
Programmatically Trigger Gravity Forms Notification
<?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 );
}
?>
@connistock
Copy link

I have a similar question as @offordscott. I need to send an email notification when form is approved. Currently, I have a notification for form received. I have included a hidden check box field with Approved, Pending, Incomplete, Duplicate options. I would like to create a email notification to be triggered when the Approved box has been selected. Is this possible? with this type of code. Any information where I can learn to create this action would be very helpful. Also, @offordscott did you get any response?

@anvilzephyr
Copy link

anvilzephyr commented Aug 10, 2018

To send a notification after a manual edit to the entry (ie selecting 'Approved' in a radio button) use the 'gform_after_update_entry' action hook. Your notification should be conditional to the radio button value is 'Approved' if you don't want it to be sent immediately. Then after an update to the entry you can trigger the send. If the condition is then met, it will send.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment