Skip Navigation

[Resolved] How can we update a custom file upload file value?

This support ticket is created 4 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 8 replies, has 2 voices.

Last updated by matthewS-9 4 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1694337

Tell us what you are trying to do?
1. We have a custom field "File Upload" with "Allow multiple instances of this field" selected.
2. We have an array $file_links with several file links.
3. How can we update the custom field "File Upload" value with the array?
4. We already tried
update_post_meta($post_id, 'wpcf-file-upload', $file_links);
but it seems that it does not work.
5. Please advise.

#1697651

Hello,

For multiple instance field, you can try function add_post_meta(), for example:

delete_post_meta($post_id,  'wpcf-file-upload');
foreach($file_links as $k=>$v){
	add_post_meta($post_id,  'wpcf-file-upload', $v);
}

More help:
https://developer.wordpress.org/reference/functions/delete_post_meta/
https://developer.wordpress.org/reference/functions/add_post_meta/

#1704987

This may relate to another issue https://toolset.com/forums/topic/ajax-does-not-work-when-uploading-additional-files-to-a-file-upload-field/

We shall try this solution after fixing the issue above.

#1706261

I have answered the thread you mentioned above, please check it, thanks

#1706763

Thank you!

However it seems that the issue has not been fully fixed yet.

Please review it here https://toolset.com/forums/topic/ajax-does-not-work-when-uploading-additional-files-to-a-file-upload-field/

#1707627

I have escalated that thread, please let me know if you need more assistance for this thread, thanks

#1707911

Thanks, Luo.

The code in this thread does not work for a form with enabled AJAX and disabled option "Use the WordPress Media Library manager for image, video, audio, or file fields." (when one additional file is added a previous file is lost)

We shall recheck it when when there is a patch for https://toolset.com/forums/topic/ajax-does-not-work-when-uploading-additional-files-to-a-file-upload-field/

#1708285

That issue has been confirmed as a bug
https://toolset.com/forums/topic/ajax-does-not-work-when-uploading-additional-files-to-a-file-upload-field/

can we close this one, and follow above one?

#1708869

My issue is resolved now. Thank you!