PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Attach generated PDF to user notification Email

  1. swolf
    Member

    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";
    	}
    	}
    }
    Posted 11 years ago on Tuesday August 21, 2012 | Permalink
  2. Check this out and see if it helps:

    http://www.gravityhelp.com/forums/topic/use-pre-selected-file-as-user-notification-attachment#post-53767

    Posted 11 years ago on Tuesday August 21, 2012 | Permalink
  3. swolf
    Member

    Works great, thank you!

    Posted 11 years ago on Tuesday August 21, 2012 | Permalink
  4. Right on, glad to help.

    Posted 11 years ago on Tuesday August 21, 2012 | Permalink

This topic has been resolved and has been closed to new replies.