Okay, I’ve been fighting with this for a while and realized I need help.
I have a function that creates a new post using AJAX from a front end form. That all works fine, I can even get the ACF data to save in the back end. So when I save the post I go see look at it and all the data is there.
However when I go to the page that should have that data it’s not there, only the basic post fields are. Now stranger is if I open that post in the back end and just click update, nothing else, everything works just fine.
Also very oddly last_name doesn’t work at all, that is the correct field name, it just doesn’t return a key.
Any idea what I am doing wrong?
Point of note: $city = get_field_object(‘city’); and then $city[‘key’] returns field_city, not the normal field_some_hash that I see everyone else posting. Why is that?
function save_pledge_post($data) {
$new_post = array(
'post_title' =>$data['name'],
'post_status' => 'publish',
'post_author' => 1,
'post_type' => 'pledgers'
);
$post_id = wp_insert_post($new_post);
$last_name = get_field_object('last_name');
$city = get_field_object('city');
$postal_code = get_field_object('postal_code');
$email = get_field_object('email');
$latitude = get_field_object('latitude');
$longitude = get_field_object('longitude');
$image = get_field_object('image');
$pldege_type = get_field_object('pldege_type');
update_field($last_name['key'], $data['last_name'], $post_id);
update_field($city['key'], $data['city'], $post_id);
update_field($postal_code['key'], $data['postal_code'], $post_id);
update_field($email['key'], $data['email'], $post_id);
update_field($latitude['key'], $data['latitude'], $post_id);
update_field($longitude['key'], $data['longitude'], $post_id);
update_field($image['key'], $data['image'], $post_id);
update_field($pldege_type['key'], $data['pldegeType'], $post_id);
return $post_id;
}