Hi all,
I’m pretty sure it is possible to update piklist field programmatically, but can anyone help with simple snippet for updating repeater field. Here is my use case:
I have complex front-end form build with Vuejs. I send the form to admin-ajax.php ( with action, nonce, etc ), create new post. Here is a simplified snippet:
$new_post = array(
'post_title' => wp_strip_all_tags($_POST['title']),
'post_status' => 'draft',
'meta_input' => array(
'piklist_field_here' => 'form_value_here',
)
);
if (wp_insert_post($new_post)) {
echo json_encode(array('status' => 'ok', 'message' => 'ok'));
}
It works for simple fields ( creates post, adds the meta, editable with Piklist ), but It doesn’t work for arrays ( add_more / repeater fields ). My question is how I can use Piklist api to add array as meta and show it in repeater field.
I know that the Piklist front-end forms are made for jus this scenario, but in my case they’re not an option. Just simple snippet array => repeater field would be appreciated. Exposing public API for meta would also benefit a lot of people, I think.
Thanks in advance,
Chris