Home › Forums › General Issues › Populate ACF File field from Gravity Forms › Reply To: Populate ACF File field from Gravity Forms
The issue with the code that you posted is that is says
update_field( 'YOUR_FIELD_NAME', $attachment_id, $post_id );
If you use the field name as this code suggests, and the field does not already have a value (exists in the database) then the ACF field will not be updated properly. When updating fields that do not already have values you must use the field key instead of the field name.
This is covered in the update_field() documentation https://www.advancedcustomfields.com/resources/acf-update_field/
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.