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.

Getting Attachment link

  1. vixvii
    Member

    I am using an attachment in my form which is emailed to several users. I know GF just has a link to the uploaded file, but I cannot seem to get this link.

    Could you maybe tell me how I can retrieve the url to the attached file in a post_submission function?

    Currently I use $attachments = $_POST["input_4"]; But this just gives me a blank value

    Thanks

    Posted 10 years ago on Monday August 22, 2011 | Permalink
  2. Since you are using gform_post_submission, you have access to the $entry. Try this:

    [php]
    $attachments = $entry[4];
    Posted 10 years ago on Monday August 22, 2011 | Permalink
  3. vixvii
    Member

    Thanks, but still not getting any value. The file does get uploaded to the server though...

    My code is quite long, but here it is : http://www.pastie.org/2413213

    Unfortunately the form is on a protected page, but the html code is : http://www.pastie.org/2413223

    I am also aware that I am using wp_mail($email_addresses[$i], $subject, $message, $headers, $attachments); - but I am not worried about the $attachment in this function for now, I just want to send the $attachment_link in the message body.

    Posted 10 years ago on Monday August 22, 2011 | Permalink
  4. Can you change the first two lines in your code and make it work?

    [php]
    add_action("gform_post_submission_18", "post_sendmail_handler", 10, 2);
    function post_sendmail_handler($entry, $form){

    According to the docs, the gform_post_submission hook takes 2 arguments, $entry and $form, but you are only sending $form. I think that's why the entry values are not available. I think if you do it this way you won't have to use the $_POST global either. But please try these two changes and see if that works.

    Posted 10 years ago on Tuesday August 23, 2011 | Permalink
  5. vixvii
    Member

    Hi Chris,

    It's working! Thanks again for the help!

    Posted 10 years ago on Tuesday August 23, 2011 | Permalink
  6. No problem. I was just working on something similar for myself and had to refer back to this post!

    Posted 10 years ago on Tuesday August 23, 2011 | Permalink

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