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.

Attachment Fields to Edit

  1. elizabethanne
    Member

    I have two fields that I have added to attachments and the media uploader using the standard WP functions 'attachment fields to edit' and 'attachment fields to save'. They are photographer URL and photographer name.

    Is there any way using gravity forms that I can have the post image field capture this information, or have a custom field or single line text field/website field map to these attachment fields?

    I have been able to do the custom fields for the post as a whole using the custom field mapping functionality, so all good there.

    Thank you!

    Posted 11 years ago on Monday July 23, 2012 | Permalink
  2. I believe the new fields you create are stored in the postmeta table, so you should be able to use the same procedure as you already have for custom field mapping. Add a custom field to your form, and associate it with the meta key you used to extend the media.

    Reference:
    http://net.tutsplus.com/tutorials/wordpress/creating-custom-fields-for-attachments-in-wordpress/

    The new fields being added will be saved as post meta, just like the custom fields section of the post/page edit screen.

    Posted 11 years ago on Monday July 23, 2012 | Permalink
  3. elizabethanne
    Member

    hi chris, thanks for your response!

    yes, that's where the fields are stored. the issue i'm running into is that gravity forms seems to only want to update the postmeta for the actual post it's creating (the parent) vs the children (the attachments). so the code would basically need to look at the ID for the post image being created when the form is uploaded, and add the custom field to the postmeta for that ID. does that make sense? thanks for any direction!

    Posted 11 years ago on Monday July 23, 2012 | Permalink
  4. Oh yeah. Good point. It's not the postmeta for the post being created, it's the postmeta for the media which is being uploaded, right? Interesting problem. Let me create a test form with some uploads and see if I can get the ID of the attachments and update the postmeta there.

    Posted 11 years ago on Monday July 23, 2012 | Permalink
  5. elizabethanne
    Member

    yes, that's exactly the problem i'm running into! thanks for looking, chris!

    Posted 11 years ago on Tuesday July 24, 2012 | Permalink
  6. elizabethanne
    Member

    hi chris! any luck on this? thank you!

    Posted 11 years ago on Thursday August 2, 2012 | Permalink
  7. I started working on this, but I need to know the name of the fields being used to store the data in the postmeta table. Do you have the meta key names for the photographer URL and name? I will incorporate those into the function.

    Are you uploading just one image in your form?

    Also, is this form online now, so I can see what fields you are using to capture the information, or can you export the form and email it to me at chris@rocketgenius.com please.

    The general procedure will be to grab to ID of the children (using the WordPress get_children function) of the post which was just created (those will be the attachments - or just one attachment?) then use the gform_after_submission hook to update those two meta values based on the information you captured in your form. Maybe that's enough information to go on, but if not, I will need a bit more information from you to continue working on this. Thanks.

    Posted 11 years ago on Monday August 6, 2012 | Permalink
  8. elizabethanne
    Member

    hi chris! i will export and email you the form. the photographer URL meta key is: ent_photographer_url and the photographer name is: ent_photographer_name.

    the user can upload up to 60 images, but the info for all images they upload must be the same photographer.

    thank you for your help!

    Posted 11 years ago on Tuesday August 7, 2012 | Permalink
  9. Thanks for the info. I will take a look at this on Tuesday.

    Posted 11 years ago on Tuesday August 7, 2012 | Permalink
  10. elizabethanne
    Member

    thank you!

    Posted 11 years ago on Tuesday August 7, 2012 | Permalink
  11. Hi Ami. Take a look at this code: http://pastebin.com/dy0eHKgQ

    Place that in your theme's functions.php. You may have to remove the opening <?php depending on where you paste it in. Change the "122" on line 4 to your form ID. Other than that, I think it should work fine. Let me know if you have any questions.

    Posted 11 years ago on Friday August 10, 2012 | Permalink
  12. elizabethanne
    Member

    hi! thanks chris - i am sorry for the delay I was on vacation, will try this over the weekend and let you know how it goes! thanks again!

    Posted 11 years ago on Thursday August 16, 2012 | Permalink
  13. elizabethanne
    Member

    this worked like a charm! thank you SO MUCH chris!

    Posted 11 years ago on Friday September 28, 2012 | Permalink
  14. Thank you for the update.

    Posted 11 years ago on Friday September 28, 2012 | Permalink

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