• Resolved fijisunshine

    (@fijisunshine)


    Great plugin!

    I’ve read several of your support posts regarding mapping file fields. However, I don’t understand your solutions:

    “ACF likely expects a file ID to be saved in its field.

    This plugin was initally designed to automatically create fields which a form are mapped to. File meta-fields are saved as a link to the url of hte file, and as a result ACF created file fields do not recognise the url string a valid field.

    You should let the plugin handle the field creation for you. Else if you really want to use ACF, then map your field to a custom filter and programmatically save the file in the format ACF expects it.”

    Can you explain step-by-step the easiest way to map a file field to an image (or any file)? I’d like users to be able to upload an image file and map it to the database.

    Thank you

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    Great plugin!

    thank you, please do leave a review when you have a moment to spare.

    Can you explain step-by-step the easiest way to map a file field to an image (or any file)? I’d like users to be able to upload an image file and map it to the database.

    don’t use ACF field for files, unless you know what you’re doing.

    Do you need your uploaded file to be the post featured image? Or do you need it to be in a meta field?

    How do you want to use the file once it is saved?

    Thread Starter fijisunshine

    (@fijisunshine)

    Thank you for your response, Aurovrata.

    For my custom post type, I have a Type = “Image” field created using the Advanced Custom Fields plugin. I also have several “Text” fields. So I use your plugin for the user to submit some text data for the “Text” fields. Then, they email me their image and I manually upload their image to their custom post in the WordPress admin backend. To automate this process, I’d like to use your plugin so that they can just upload their image file (in addition to entering their text data).

    Once they upload their image, it would be great if their image was in the same location in the WordPress admin backend that it would be if I just uploaded it manually to their custom post. I could then hover on their image, click “Edit”, and crop it.

    To answer your questions: If I understand correctly, I don’t think their image has to be the post featured image. I think their image should be a meta field.

    Thanks again

    Plugin Author Aurovrata Venet

    (@aurovrata)

    For my custom post type, I have a Type = “Image” field created using the Advanced Custom Fields plugin

    so previous users have faced difficulties mapping images to meta-fields created using ACF. I believe ACF stores the media post ID in its meta-field, while the Post My CF7 plugin saves the image URL in the meta-field.

    When an image is uploaded to your server it is located in the uploads directory, the plugin automatically saves the URL link to that location.

    Once they upload their image, it would be great if their image was in the same location in the WordPress admin backend that it would be if I just uploaded it manually to their custom post

    then you will need to hook the action after the form is submitted (see the screenshot #8) and programmatically load your image into a media attachment post, and saved the resulting post ID into your ACF meta-field.

    Thread Starter fijisunshine

    (@fijisunshine)

    Thank you for your response. Lets break down your last paragraph in more detail to help clarify.

    1. “then you will need to hook the action after the form is submitted (see the screenshot #8)”

    Do you mean to use an add_action in functions.php and hook on wpcf7_mail_sent?

    2. “programmatically load your image into a media attachment post”

    Are these good examples to follow to create the function in functions.php?

    a. https://wordpress.stackexchange.com/questions/256830/programmatically-adding-images-to-media-library
    b. https://wordpress.stackexchange.com/questions/238294/programmatically-adding-images-to-the-media-library-with-wp-generate-attachment

    If so, how would I get the image’s url into the function?

    3. “and saved the resulting post ID into your ACF meta-field”

    Are you saying to use update_field? If so, what type of field should the ACF meta-field be? An image?

    Thanks again

    Plugin Author Aurovrata Venet

    (@aurovrata)

    Do you mean to use an add_action in functions.php and hook on wpcf7_mail_sent?

    not quite, follow my instructions, see and read the screenshot on the plugin page please.

    Are these good examples to follow to create the function in functions.php?

    if you understand the code and can adapt it to your need, yes, however if you don’t understand it I would highly recommend you hire someone to do it as you may end up odd results.

    If so, how would I get the image’s url into the function?

    fetch the uploaded file using the global $_FILES variable.

    If so, what type of field should the ACF meta-field be? An image?

    sorry, I can’t help you here as I have never made use of that plugin, best to ask on the support forum for the ACF plugin.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Mapping file field to image (or any file)’ is closed to new replies.