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.

Converting File Upload to Post Attachment during post-processing

  1. I'm looking to get all the benefits of having post attachments (thumbnails, image resizing, etc..) for images uploaded to a GF (complex use case alert). I'll post my progress here, if anyone has done this before feel free to save me from going through the "figuring it out" phase ;)

    Posted 13 years ago on Wednesday November 23, 2011 | Permalink
  2. On further inspection, it appears there's another field type I glossed over for Post Image. However, if I end up going forward with this code, it would convert the file uploads (regardless of file type) over to an attachment.

    Posted 13 years ago on Wednesday November 23, 2011 | Permalink
  3. So that ended up fitting my needs perfectly. Only problem is that by adding a Post Image field, upon submission - a ghost post is created called "Untitled X", with "X" being a number. To resolve this, I simply added this code to my post-processing function.

    if (0 < $entry['post_id'])
        wp_delete_post($entry['post_id'], true);

    That code will drop the post, BUT leave the attachments, which was all I needed to have anyway.

    Posted 13 years ago on Wednesday November 23, 2011 | Permalink
  4. Thanks for the update Scott.

    Posted 13 years ago on Thursday November 24, 2011 | Permalink
  5. Would you mid being more explicit into exactly how did you implement the "post-processing function"? Would that code be called by gform_after_submission filter?

    Posted 12 years ago on Thursday January 5, 2012 | Permalink
  6. Also, when creating the new attachment post, how would I know it's ID to change it's parent?

    Posted 12 years ago on Thursday January 5, 2012 | Permalink
  7. How did you get it working with uploading different file types other than images via the post image field.. pdf for example.. ?

    Posted 12 years ago on Tuesday March 27, 2012 | Permalink