Filter to pass a string or value as an array in Update Post Meta

I have a hidden field with the ID of a post. I want to pass that ID into the ‘Update Post Meta’ function to update a relationship field. However, the :array filter only seems to work with actual arrays from form fields such as repeaters and checkboxes. It doesn’t work with fields that return a single value.

Hey :slight_smile: So you want just an output like ["The single value"]?

1 Like

Yes. I believe so. I can share the URL, if needed, so you can take a look.

@Daniele, from my little research. One solution might be to append [] the name attribute of the field.

Also, I noticed that the :array filter tends to send an extra 0 after the chosen array form field values. Is there a way to remove the trailing zeroes?

I have now integrated the fix locally so that the output is always an array if the filter :array is included. If you want to test this on your side, feel free to send me access with the[sensitive] tag and I’ll integrate it for you. :slight_smile:

1 Like

Oh cool! Thanks. I’m working on a video series. The first episode is scheduled to release at 14:00 BST (UTC+1). Please let me know if there is any feature you’d like me to showcase.

[sensitive]
Login URL: Log In ‹ wordpress-1473719-5575079.cloudwaysapps.com — WordPress
Username: info@daveden.co.uk
Password: pC9S8r4hYZ
[/sensitive]