Last active
August 29, 2023 06:10
-
-
Save naomicbush/43f46dd16f1dbb1491c2 to your computer and use it in GitHub Desktop.
Programmatically Trigger Gravity Forms Notification
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 | |
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 ); | |
} | |
?> |
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
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?