Skip to content

Instantly share code, notes, and snippets.

@keithdevon
Created September 25, 2014 21:05
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save keithdevon/08016bd065397c76045c to your computer and use it in GitHub Desktop.
Save keithdevon/08016bd065397c76045c to your computer and use it in GitHub Desktop.
Manually create entries and send notifications with Gravity Forms
<?php
// Manually create entries and send notifications with Gravity Forms
$form_id = 10;
// add entry
$entry = array(
"form_id" => $form_id,
"1" => "Entry for field ID 1",
"2" => "Entry for field ID 2"
);
$entry_id = GFAPI::add_entry($entry);
// send notifications
function send_notifications($form_id, $entry_id){
// Get the array info for our forms and entries
// that we need to send notifications for
$form = RGFormsModel::get_form_meta($form_id);
$entry = RGFormsModel::get_lead($entry_id);
// Loop through all the notifications for the
// form so we know which ones to send
$notification_ids = array();
foreach($form['notifications'] as $id => $info){
array_push($notification_ids, $id);
}
// Send the notifications
GFCommon::send_notifications($notification_ids, $form, $entry);
}
send_notifications($form_id, $entry_id);
?>
@moafzalmulla
Copy link

@keithdevon any way I can pass the user email through that ?

@pratham2003
Copy link

To someone that lands here, check if you could use GFAPI::submit_form.
That handles sending emails automatically.

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