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.

Show uploaded file link with a post?

  1. I'm using Gravity Forms as a way to allow members to make posts to the front end of the site. I have added a file upload field to allow them to upload files with the post. Is there a way to display the link to that file when the post is displayed on the site (approved)?

    I'm creating a project management site where I can interact with my clients and share files/information.

    Thanks
    Andrew

    Posted 15 years ago on Saturday August 7, 2010 | Permalink
  2. Are you comfortable using page templates and custom fields? If so, your best bet will be to create a custom page template that pulls a custom field using the get_post_meta function.

    This custom field could be named something like "file_url" and it would store the file url that was uploaded from your Gravity Forms form. To autopopulate this custom field when the form is submitted, something like this should do the trick: http://pastebin.com/UnFSjh3y

    if($form['id'] != 1) return;

    Make sure you update the "1" to the id of the form you are using.

    update_post_meta($entry["post_id"], 'file_url', $entry[29]);

    Update the "29" to the id of the file upload field.

    Posted 15 years ago on Saturday August 7, 2010 | Permalink
  3. Thanks David.
    So you are suggesting I use a custom field rather than the file upload button? If so, how do I find the id number of the custom field?

    Posted 15 years ago on Saturday August 7, 2010 | Permalink
  4. Not quite. This solution assumes that you are using the file upload field. The code snippet I provided would go in your theme's functions.php file; it takes the file upload url and adds a custom field to the post that is created by the form submission. You do not need to actually create a custom field in the form itself.

    Let me know if you have any other questions. :)

    Posted 15 years ago on Saturday August 7, 2010 | Permalink
  5. OK I think I understand. So how do I determine the id of the file upload field?

    I appreciate all of your help David.

    Posted 15 years ago on Saturday August 7, 2010 | Permalink
  6. Per Carl Hancock:

    Easiest way to see the field IDS is to view source or use a page inspector like FireBug in FireFox to view the page source and see what the field ids are. They are present in the HTML.

    That is probably your best bet.

    Posted 15 years ago on Sunday August 8, 2010 | Permalink