Try using the wpuf_add_post_after_insert
hook. This hook gets triggered right after a post is created using WPUF, which means it might be a more appropriate time to save additional data, like the phone number:
add_action('wpuf_add_post_after_insert', 'update_product_acf_field_guest_submission', 10, 3);
function update_product_acf_field_guest_submission($post_id, $form_id, $form_settings) {
// Check if the form ID matches the specific form where the phone number is submitted
if ($form_id == '356') {
// Ensure phone field data exists before using it
if (isset($_POST['phone_field'])) {
$phone_number = sanitize_text_field($_POST['phone_field']);
// Update the ACF field for the WooCommerce product
update_field('acf[field_6512315ee37ae]', $phone_number, $post_id);
}
}
}
I’ve also added an additional check to ensure that the phone_field
exists in the POST data before trying to sanitize and save it, just to be safe.
Remember to replace 'acf[field_6512315ee37ae]'
with your actual field key if it’s different.