Hi,
I am using the gform_pre_submission hook to generate a pdf certificate for my forms which is working great. I'm using gform_pre_submission because I am changing the content of one of the fields to the path of the generated file.
Now I am trying to get this file attached to the user notification email but can't get that to work. I am guessing I have to use the gform_user_notification_attachments hook but don't know how to use it.
Here is my code for the gform_pre_submission function, $_POST["input_20"] contains the path to the file I want to attach:
add_action("gform_pre_submission", "set_post_content", 10, 2);
function set_post_content($form){
if ( $_POST['input_21'] = 'Test' and $_POST['input_2'] > 6 ) {
$post_url = 'pdf_zertifikat_generator.php';
$body = array(
'datum' => $_POST['input_11'],
'quiz_name' => $_POST['input_6'],
'cme' => $_POST['input_13'],
'bp_login' => $_POST['input_19'],
'wp_email' => $_POST['input_10'],
'bp_id' => $_POST['input_17'],
'score' => $_POST['input_2'],
'VNR' => $_POST['input_22']
);
if ( $_POST['input_2']>6 ) {
$request = new WP_Http();
$response = $request->post($post_url, array('body' => $body));
$_POST["input_20"] = "../pdf/zertifikate/" . $_POST['input_17'] . "_" . $_POST['input_22'] . ".pdf";
}
}
}