What i'm trying to do - i have meta field in post with array of user emails, i'd like to add new user email(if it's not there already) with each submission of Contact form 7.
Here's what i managed to do by now:
add_action('wpcf7_mail_sent',
function ($contact_form) {
if ($contact_form->id() === 32009) {
$submission = WPCF7_Submission::get_instance();
//$currentdata = get_post_meta(32127, 'customer_email');
$mail = $submission->get_posted_data('email-002');
update_post_meta(32127, 'customer_email',$mail);
}
}
);
Thing is that above code is replacing whole array with one new string and i just want to add it, not replace whole thing.
add_post_meta create duplicates and with unique="true" it doesn't add anything.
I would appreciate if anyone could explain to me how can i achieve what i need and maybe a little about updating meta fields, since reading wordpress documentation doesn't really answer my questions.
update_post_metareplaces the entire value it can't edit/append as it has no concept of "structured data"