I have now coded a way to send a confirmation email from the admin entry page. I will share it here in case others might need this function. :-)
// ------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------
/**
* Gravity form - add a send confirmation email to entry admin panel.
*/
add_action("gform_entry_info", "confirmation_button", 10, 2);
function confirmation_button($form_id, $lead) {
if(!class_exists("GFEntryDetail"))
require_once(GFCommon::get_base_path() . "/entry_detail.php");
if(!class_exists("RGFormsModel"))
require_once(GFCommon::get_base_path() . "/forms_model.php");
if(!class_exists("GFCommon"))
require_once(GFCommon::get_base_path() . "/common.php");
if( class_exists("RGFormsModel") && class_exists("GFCommon") ) { ?>
<h4>Send email</h4>
<p>Send a confirmation email to the user</p>
<input type="submit" name="send_admin_notification" value="<?php _e("Send to user", "gravityforms") ?>" class="button" style="width:100px;" onclick="jQuery('#action').val('send_user_notification');"/>
<?php
if( isset($_POST['action']) && trim($_POST['action']) === 'send_user_notification' ) {
// Initiate the form
$form = RGFormsModel::get_form_meta($form_id);
// The AutoResponder is not activated in the admin, so activate it here by giving it the ID number of the email field.
$form["autoResponder"]['toField'] = 31;
// Send an email to the user
GFCommon::send_user_notification($form, $lead);
// Send email to the admin
//GFCommon::send_admin_notification($form, $lead);
echo '<p>The email has been sendt.</p>';
}
}
}
If there is a better way to do this I am certainly open for suggestions.
Vayu
Posted 13 years ago on Thursday May 26, 2011 |
Permalink