Home › Forums › Bug Reports › update_field() inconsistency
Create a new Field Group with a repeater. In that repeater add a text field and save it.
In the WordPress admin, create a new post and add 1 or more items to that repeater and publish the post.
call get_field() with the field name for the repeater and you get an array containing all of the repeated elements.
Modify the contents of that array and then use update_field() to update the content of that repeater field and the new contents are properly stored by ACF. Everything works great.
Now, use wp_insert_post() to create a new post. Then call update_field() with the name of that repeater field and an array of content. The data is not properly stored by ACF and a call to get_field() afterward fails.
It is not possible to create a post in code and add anything but “basic” field type data to that post. Term Objects don’t work, Groups don’t work, User Objects don’t work, etc… Even if you use the FIELD_???? ID instead of the field name. It still doesn’t properly store the data for ACF to be able to read it back.
I need to import data from an external REST API source and create hundreds of new posts a day and ACF fails to properly create the data so that it can read it back. It only works if a post is manually created in the admin using the ACF form.
To me, this is a serious bug.
I’m not exactly sure where your the problem is, but I just tried inserting a new post and then updating a repeater field and it worked for me.
Here is the test code that I ran
$post = array(
'post_type' => 'post',
'post_title' => 'inserted post test 2',
'post_status' => 'publish',
'post_content' => 'test content',
);
$post_id = wp_insert_post($post);
$value = array(
array(
'field_5c1abd1da3f56' => 'test update field'
)
);
update_field('field_5c1abd11a3f55', $value, $post_id);
field_5c1abd11a3f55 is a repeater?
And field_5c1abd1da3f56 is a text field?
Okay, that seems to work with a very simply repeater field.
Try this. Create a Group. Within that group, create a repeater with 3 fields.
Create a post in the admin area as normal.
Use the FIELD_ID and the POST_ID in get_field() to get the data for that group. You should get a nested array.
Modify that array and use update_field() to put the data back. It should work just fine.
Now, wp_insert_post() to create a post. Use get_field() to get the data from the first post with valid data. Use update_field() to copy that data into the new post. If fails.
This is my code:
$date_meta = array();
$date_meta['field_5b21449202e42'] = 'date'; //event_date_type
$date_meta['field_5b2145b902e43'][0] = array( //event_single_day
'field_5b21463202e44' => $date, //event_date
'field_5b2146c83d961' => array( //event_time
0 => array(
'field_5b2147733d964' => $time, //event_start_time
'field_5b2147af3d965' => $time, //event_end_time
)
)
);
update_field( 'field_5b21463202e44', $date_meta, $id ); //event_date
error_log( print_r( get_field( 'field_5b21463202e44', $id ), true ) );
error_log shows “false”.
If I look at the raw fields, “event_date” has the array stored as an array and none of the ACF FIELDs are created.
Yes, getting a value and then using that value to update another post with the same data will fail, I don’t even need to test it. The reason is that when you use get_field(), even if you use the field key, the nested sub fields in it will be by field name and not field key, so it fails.
In your code example:
$date_meta = array();
$date_meta['field_5b21449202e42'] = 'date'; //event_date_type
$date_meta['field_5b2145b902e43'][0] = array( //event_single_day
// this is the field your are updating in the
// update field call below
'field_5b21463202e44' => $date, //event_date
'field_5b2146c83d961' => array( //event_time
0 => array(
'field_5b2147733d964' => $time, //event_start_time
'field_5b2147af3d965' => $time, //event_end_time
)
)
);
update_field( 'field_5b21463202e44', $date_meta, $id ); //event_date
field_5b21463202e44 looks like a nested repeater, see my notes above. Is this correct?
It’s repeaters nested inside of a group… Very complex:
Array
(
[ID] => 10198
[key] => field_5b21445c02e41
[label] => Event Date
[name] => event_date
[prefix] => acf
[type] => group
[value] => Array
(
[event_date_type] => date
[event_single_day] => Array
(
[0] => Array
(
[event_date] => 20181219
[event_time] => Array
(
[0] => Array
(
[event_start_time] => 10:00:00
[event_end_time] => 10:30:00
)
[1] => Array
(
[event_start_time] => 10:30:00
[event_end_time] => 11:00:00
)
)
)
)
[event_date_range] =>
[event_recurring_weekly] => Array
(
[event_start_date] =>
[event_end_date] =>
[event_time] =>
[event_recurring_days] => Array
(
)
)
[event_recurring_monthly] =>
)
[menu_order] => 8
[instructions] =>
[required] => 1
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 15
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] => event_date
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[layout] => block
[sub_fields] => Array
(
[0] => Array
(
[ID] => 10199
[key] => field_5b21449202e42
[label] => Type
[name] => event_date_type
[prefix] => acf
[type] => select
[value] =>
[menu_order] => 0
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10198
[wrapper] => Array
(
[width] => 25
[class] =>
[id] =>
)
[_name] => event_date_type
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[choices] => Array
(
[date] => Single Day Event
[range] => Date Range
[weekly] => Recurring Weekly
[monthly] => Recurring Monthly
)
[default_value] => Array
(
[0] => date
)
[allow_null] => 0
[multiple] => 0
[ui] => 0
[return_format] => value
[ajax] => 0
[placeholder] =>
)
[1] => Array
(
[ID] => 10200
[key] => field_5b2145b902e43
[label] => Single Day Event
[name] => event_single_day
[prefix] => acf
[type] => repeater
[value] =>
[menu_order] => 1
[instructions] => Events that occur on a single day. You may add multiple dates and times, but each date/time is distinct and will have separate registrations, if registration is required.
[required] => 0
[id] =>
[class] =>
[conditional_logic] => Array
(
[0] => Array
(
[0] => Array
(
[field] => field_5b21449202e42
[operator] => ==
[value] => date
)
)
)
[parent] => 10198
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] => event_single_day
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[collapsed] => field_5b21463202e44
[min] => 1
[max] => 0
[layout] => block
[button_label] => Add Another Date
[sub_fields] => Array
(
[0] => Array
(
[ID] => 10201
[key] => field_5b21463202e44
[label] => Date
[name] => event_date
[prefix] => acf
[type] => date_picker
[value] =>
[menu_order] => 0
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10200
[wrapper] => Array
(
[width] => 20
[class] =>
[id] =>
)
[_name] => event_date
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[display_format] => m/d/Y
[return_format] => Ymd
[first_day] => 0
)
[1] => Array
(
[ID] => 10202
[key] => field_5b2146c83d961
[label] => Time
[name] => event_time
[prefix] => acf
[type] => repeater
[value] =>
[menu_order] => 1
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10200
[wrapper] => Array
(
[width] => 79
[class] =>
[id] =>
)
[_name] => event_time
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[collapsed] =>
[min] => 1
[max] => 0
[layout] => table
[button_label] => Add Time
[sub_fields] => Array
(
[0] => Array
(
[ID] => 10203
[key] => field_5b2147733d964
[label] => Start Time
[name] => event_start_time
[prefix] => acf
[type] => select
[value] =>
[menu_order] => 0
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10202
[wrapper] => Array
(
[width] => 49
[class] =>
[id] =>
)
[_name] => event_start_time
[_prepare] => 0
[_valid] => 1
[choices] => Array
(
[06:00:00] => 6:00am
[06:15:00] => 6:15am
[06:30:00] => 6:30am
[06:45:00] => 6:45am
[07:00:00] => 7:00am
[07:15:00] => 7:15am
[07:30:00] => 7:30am
[07:45:00] => 7:45am
[08:00:00] => 8:00am
[08:15:00] => 8:15am
[08:30:00] => 8:30am
[08:45:00] => 8:45am
[09:00:00] => 9:00am
[09:15:00] => 9:15am
[09:30:00] => 9:30am
[09:45:00] => 9:45am
[10:00:00] => 10:00am
[10:15:00] => 10:15am
[10:30:00] => 10:30am
[10:45:00] => 10:45am
[11:00:00] => 11:00am
[11:15:00] => 11:15am
[11:30:00] => 11:30am
[11:45:00] => 11:45am
[12:00:00] => 12:00pm
[12:15:00] => 12:15pm
[12:30:00] => 12:30pm
[12:45:00] => 12:45pm
[13:00:00] => 1:00pm
[13:15:00] => 1:15pm
[13:30:00] => 1:30pm
[13:45:00] => 1:45pm
[14:00:00] => 2:00pm
[14:15:00] => 2:15pm
[14:30:00] => 2:30pm
[14:45:00] => 2:45pm
[15:00:00] => 3:00pm
[15:15:00] => 3:15pm
[15:30:00] => 3:30pm
[15:45:00] => 3:45pm
[16:00:00] => 4:00pm
[16:15:00] => 4:15pm
[16:30:00] => 4:30pm
[16:45:00] => 4:45pm
[17:00:00] => 5:00pm
[17:15:00] => 5:15pm
[17:30:00] => 5:30pm
[17:45:00] => 5:45pm
[18:00:00] => 6:00pm
[18:15:00] => 6:15pm
[18:30:00] => 6:30pm
[18:45:00] => 6:45pm
[19:00:00] => 7:00pm
[19:15:00] => 7:15pm
[19:30:00] => 7:30pm
[19:45:00] => 7:45pm
[20:00:00] => 8:00pm
[20:15:00] => 8:15pm
[20:30:00] => 8:30pm
[20:45:00] => 8:45pm
[21:00:00] => 9:00pm
[21:15:00] => 9:15pm
[21:30:00] => 9:30pm
[21:45:00] => 9:45pm
[22:00:00] => 10:00pm
[22:15:00] => 10:15pm
[22:30:00] => 10:30pm
[22:45:00] => 10:45pm
[23:00:00] => 11:00pm
[23:15:00] => 11:15pm
[23:30:00] => 11:30pm
[23:45:00] => 11:45pm
[00:00:00] => 12:00am
)
[default_value] => Array
(
[0] => 07:00:00
)
[allow_null] => 0
[multiple] => 0
[ui] => 0
[return_format] => value
[ajax] => 0
[placeholder] =>
)
[1] => Array
(
[ID] => 10204
[key] => field_5b2147af3d965
[label] => End Time
[name] => event_end_time
[prefix] => acf
[type] => select
[value] =>
[menu_order] => 1
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10202
[wrapper] => Array
(
[width] => 50
[class] =>
[id] =>
)
[_name] => event_end_time
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[choices] => Array
(
[06:00:00] => 6:00am
[06:15:00] => 6:15am
[06:30:00] => 6:30am
[06:45:00] => 6:45am
[07:00:00] => 7:00am
[07:15:00] => 7:15am
[07:30:00] => 7:30am
[07:45:00] => 7:45am
[08:00:00] => 8:00am
[08:15:00] => 8:15am
[08:30:00] => 8:30am
[08:45:00] => 8:45am
[09:00:00] => 9:00am
[09:15:00] => 9:15am
[09:30:00] => 9:30am
[09:45:00] => 9:45am
[10:00:00] => 10:00am
[10:15:00] => 10:15am
[10:30:00] => 10:30am
[10:45:00] => 10:45am
[11:00:00] => 11:00am
[11:15:00] => 11:15am
[11:30:00] => 11:30am
[11:45:00] => 11:45am
[12:00:00] => 12:00pm
[12:15:00] => 12:15pm
[12:30:00] => 12:30pm
[12:45:00] => 12:45pm
[13:00:00] => 1:00pm
[13:15:00] => 1:15pm
[13:30:00] => 1:30pm
[13:45:00] => 1:45pm
[14:00:00] => 2:00pm
[14:15:00] => 2:15pm
[14:30:00] => 2:30pm
[14:45:00] => 2:45pm
[15:00:00] => 3:00pm
[15:15:00] => 3:15pm
[15:30:00] => 3:30pm
[15:45:00] => 3:45pm
[16:00:00] => 4:00pm
[16:15:00] => 4:15pm
[16:30:00] => 4:30pm
[16:45:00] => 4:45pm
[17:00:00] => 5:00pm
[17:15:00] => 5:15pm
[17:30:00] => 5:30pm
[17:45:00] => 5:45pm
[18:00:00] => 6:00pm
[18:15:00] => 6:15pm
[18:30:00] => 6:30pm
[18:45:00] => 6:45pm
[19:00:00] => 7:00pm
[19:15:00] => 7:15pm
[19:30:00] => 7:30pm
[19:45:00] => 7:45pm
[20:00:00] => 8:00pm
[20:15:00] => 8:15pm
[20:30:00] => 8:30pm
[20:45:00] => 8:45pm
[21:00:00] => 9:00pm
[21:15:00] => 9:15pm
[21:30:00] => 9:30pm
[21:45:00] => 9:45pm
[22:00:00] => 10:00pm
[22:15:00] => 10:15pm
[22:30:00] => 10:30pm
[22:45:00] => 10:45pm
[23:00:00] => 11:00pm
[23:15:00] => 11:15pm
[23:30:00] => 11:30pm
[23:45:00] => 11:45pm
[00:00:00] => 12:00am
)
[default_value] => Array
(
[0] => 08:00:00
)
[allow_null] => 0
[multiple] => 0
[ui] => 0
[return_format] => value
[ajax] => 0
[placeholder] =>
)
)
)
)
)
[2] => Array
(
[ID] => 10214
[key] => field_5b2155730460b
[label] => Date Range
[name] => event_date_range
[prefix] => acf
[type] => repeater
[value] =>
[menu_order] => 2
[instructions] => Events that occur over a range of multiple dates with no time specified. You can add multiple date ranges.
[required] => 0
[id] =>
[class] =>
[conditional_logic] => Array
(
[0] => Array
(
[0] => Array
(
[field] => field_5b21449202e42
[operator] => ==
[value] => range
)
)
)
[parent] => 10198
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] => event_date_range
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[collapsed] =>
[min] => 1
[max] => 0
[layout] => block
[button_label] => Add New Date Range
[sub_fields] => Array
(
[0] => Array
(
[ID] => 10215
[key] => field_5b2155e50460c
[label] => Start Date
[name] => event_start_date
[prefix] => acf
[type] => date_picker
[value] =>
[menu_order] => 0
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10214
[wrapper] => Array
(
[width] => 20
[class] =>
[id] =>
)
[_name] => event_start_date
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[display_format] => m/d/Y
[return_format] => Ymd
[first_day] => 0
)
[1] => Array
(
[ID] => 10216
[key] => field_5b2156130460d
[label] => End Date
[name] => event_end_date
[prefix] => acf
[type] => date_picker
[value] =>
[menu_order] => 1
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10214
[wrapper] => Array
(
[width] => 20
[class] =>
[id] =>
)
[_name] => event_end_date
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[display_format] => m/d/Y
[return_format] => Ymd
[first_day] => 0
)
)
)
[3] => Array
(
[ID] => 10221
[key] => field_5b215748a5c71
[label] => Recurring Weekly
[name] => event_recurring_weekly
[prefix] => acf
[type] => group
[value] =>
[menu_order] => 3
[instructions] => Select the days of the week the event will reoccur. Ex: Selecting Thursday will create the event EVERY Thursday. You can select multiple days of the week.
[required] => 0
[id] =>
[class] =>
[conditional_logic] => Array
(
[0] => Array
(
[0] => Array
(
[field] => field_5b21449202e42
[operator] => ==
[value] => weekly
)
)
)
[parent] => 10198
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] => event_recurring_weekly
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[layout] => block
[sub_fields] => Array
(
[0] => Array
(
[ID] => 10223
[key] => field_5b21585026e20
[label] => Start Date
[name] => event_start_date
[prefix] => acf
[type] => date_picker
[value] => 12/19/2018
[menu_order] => 0
[instructions] => Date the event will start recurring.
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10221
[wrapper] => Array
(
[width] => 20
[class] =>
[id] =>
)
[_name] => event_start_date
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[display_format] => m/d/Y
[return_format] => Ymd
[first_day] => 0
)
[1] => Array
(
[ID] => 10224
[key] => field_5b21587526e21
[label] => End Date
[name] => event_end_date
[prefix] => acf
[type] => date_picker
[value] =>
[menu_order] => 1
[instructions] => Leave blank for no end date.
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10221
[wrapper] => Array
(
[width] => 20
[class] =>
[id] =>
)
[_name] => event_end_date
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[display_format] => m/d/Y
[return_format] => Ymd
[first_day] => 0
)
[2] => Array
(
[ID] => 10249
[key] => field_5b2168d4f6092
[label] => Time
[name] => event_time
[prefix] => acf
[type] => repeater
[value] =>
[menu_order] => 2
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10221
[wrapper] => Array
(
[width] => 49
[class] =>
[id] =>
)
[_name] => event_time
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[collapsed] =>
[min] => 1
[max] => 0
[layout] => table
[button_label] => Add Time
[sub_fields] => Array
(
[0] => Array
(
[ID] => 10250
[key] => field_5b2168fff6093
[label] => Start Time
[name] => event_start_time
[prefix] => acf
[type] => select
[value] =>
[menu_order] => 0
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10249
[wrapper] => Array
(
[width] => 33
[class] =>
[id] =>
)
[_name] => event_start_time
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[choices] => Array
(
[06:00:00] => 6:00am
[06:15:00] => 6:15am
[06:30:00] => 6:30am
[06:45:00] => 6:45am
[07:00:00] => 7:00am
[07:15:00] => 7:15am
[07:30:00] => 7:30am
[07:45:00] => 7:45am
[08:00:00] => 8:00am
[08:15:00] => 8:15am
[08:30:00] => 8:30am
[08:45:00] => 8:45am
[09:00:00] => 9:00am
[09:15:00] => 9:15am
[09:30:00] => 9:30am
[09:45:00] => 9:45am
[10:00:00] => 10:00am
[10:15:00] => 10:15am
[10:30:00] => 10:30am
[10:45:00] => 10:45am
[11:00:00] => 11:00am
[11:15:00] => 11:15am
[11:30:00] => 11:30am
[11:45:00] => 11:45am
[12:00:00] => 12:00pm
[12:15:00] => 12:15pm
[12:30:00] => 12:30pm
[12:45:00] => 12:45pm
[13:00:00] => 1:00pm
[13:15:00] => 1:15pm
[13:30:00] => 1:30pm
[13:45:00] => 1:45pm
[14:00:00] => 2:00pm
[14:15:00] => 2:15pm
[14:30:00] => 2:30pm
[14:45:00] => 2:45pm
[15:00:00] => 3:00pm
[15:15:00] => 3:15pm
[15:30:00] => 3:30pm
[15:45:00] => 3:45pm
[16:00:00] => 4:00pm
[16:15:00] => 4:15pm
[16:30:00] => 4:30pm
[16:45:00] => 4:45pm
[17:00:00] => 5:00pm
[17:15:00] => 5:15pm
[17:30:00] => 5:30pm
[17:45:00] => 5:45pm
[18:00:00] => 6:00pm
[18:15:00] => 6:15pm
[18:30:00] => 6:30pm
[18:45:00] => 6:45pm
[19:00:00] => 7:00pm
[19:15:00] => 7:15pm
[19:30:00] => 7:30pm
[19:45:00] => 7:45pm
[20:00:00] => 8:00pm
[20:15:00] => 8:15pm
[20:30:00] => 8:30pm
[20:45:00] => 8:45pm
[21:00:00] => 10:00pm
[21:15:00] => 9:15pm
[21:30:00] => 9:30pm
[21:45:00] => 9:45pm
[22:00:00] => 10:00pm
[22:15:00] => 10:15pm
[22:30:00] => 10:30pm
[22:45:00] => 10:45pm
[23:00:00] => 11:00pm
[23:15:00] => 11:15pm
[23:30:00] => 11:30pm
[23:45:00] => 11:45pm
[00:00:00] => 12:00am
)
[default_value] => Array
(
[0] => 07:00:00
)
[allow_null] => 0
[multiple] => 0
[ui] => 0
[ajax] => 0
[return_format] => value
[placeholder] =>
)
[1] => Array
(
[ID] => 10251
[key] => field_5b21692cf6094
[label] => End Time
[name] => event_end_time
[prefix] => acf
[type] => select
[value] =>
[menu_order] => 1
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10249
[wrapper] => Array
(
[width] => 33
[class] =>
[id] =>
)
[_name] => event_end_time
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[choices] => Array
(
[06:00:00] => 6:00am
[06:15:00] => 6:15am
[06:30:00] => 6:30am
[06:45:00] => 6:45am
[07:00:00] => 7:00am
[07:15:00] => 7:15am
[07:30:00] => 7:30am
[07:45:00] => 7:45am
[08:00:00] => 8:00am
[08:15:00] => 8:15am
[08:30:00] => 8:30am
[08:45:00] => 8:45am
[09:00:00] => 9:00am
[09:15:00] => 9:15am
[09:30:00] => 9:30am
[09:45:00] => 9:45am
[10:00:00] => 10:00am
[10:15:00] => 10:15am
[10:30:00] => 10:30am
[10:45:00] => 10:45am
[11:00:00] => 11:00am
[11:15:00] => 11:15am
[11:30:00] => 11:30am
[11:45:00] => 11:45am
[12:00:00] => 12:00pm
[12:15:00] => 12:15pm
[12:30:00] => 12:30pm
[12:45:00] => 12:45pm
[13:00:00] => 1:00pm
[13:15:00] => 1:15pm
[13:30:00] => 1:30pm
[13:45:00] => 1:45pm
[14:00:00] => 2:00pm
[14:15:00] => 2:15pm
[14:30:00] => 2:30pm
[14:45:00] => 2:45pm
[15:00:00] => 3:00pm
[15:15:00] => 3:15pm
[15:30:00] => 3:30pm
[15:45:00] => 3:45pm
[16:00:00] => 4:00pm
[16:15:00] => 4:15pm
[16:30:00] => 4:30pm
[16:45:00] => 4:45pm
[17:00:00] => 5:00pm
[17:15:00] => 5:15pm
[17:30:00] => 5:30pm
[17:45:00] => 5:45pm
[18:00:00] => 6:00pm
[18:15:00] => 6:15pm
[18:30:00] => 6:30pm
[18:45:00] => 6:45pm
[19:00:00] => 7:00pm
[19:15:00] => 7:15pm
[19:30:00] => 7:30pm
[19:45:00] => 7:45pm
[20:00:00] => 8:00pm
[20:15:00] => 8:15pm
[20:30:00] => 8:30pm
[20:45:00] => 8:45pm
[21:00:00] => 10:00pm
[21:15:00] => 9:15pm
[21:30:00] => 9:30pm
[21:45:00] => 9:45pm
[22:00:00] => 10:00pm
[22:15:00] => 10:15pm
[22:30:00] => 10:30pm
[22:45:00] => 10:45pm
[23:00:00] => 11:00pm
[23:15:00] => 11:15pm
[23:30:00] => 11:30pm
[23:45:00] => 11:45pm
[00:00:00] => 12:00am
)
[default_value] => Array
(
[0] => 08:00:00
)
[allow_null] => 0
[multiple] => 0
[ui] => 0
[ajax] => 0
[return_format] => value
[placeholder] =>
)
)
)
[3] => Array
(
[ID] => 10225
[key] => field_5b21589526e22
[label] => Recurring Day(s)
[name] => event_recurring_days
[prefix] => acf
[type] => checkbox
[value] =>
[menu_order] => 3
[instructions] => Select the day(s) of the week the event will reoccur. If you select Thursday, the event will repeat EVERY Thursday. You can select more than one day of the week.
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10221
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] => event_recurring_days
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[choices] => Array
(
[sunday] => Sunday
[monday] => Monday
[tuesday] => Tuesday
[wednesday] => Wednesday
[thursday] => Thursday
[friday] => Friday
[saturday] => Saturday
)
[allow_custom] => 0
[save_custom] => 0
[default_value] => Array
(
)
[layout] => horizontal
[toggle] => 0
[return_format] => value
)
)
)
[4] => Array
(
[ID] => 10230
[key] => field_5b215ddc9226e
[label] => Recurring Monthly
[name] => event_recurring_monthly
[prefix] => acf
[type] => repeater
[value] =>
[menu_order] => 4
[instructions] => Select the week number and day of the week the event will reoccur.
[required] => 0
[id] =>
[class] =>
[conditional_logic] => Array
(
[0] => Array
(
[0] => Array
(
[field] => field_5b21449202e42
[operator] => ==
[value] => monthly
)
)
)
[parent] => 10198
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] => event_recurring_monthly
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[collapsed] =>
[min] => 1
[max] => 0
[layout] => block
[button_label] => Add Recurrance
[sub_fields] => Array
(
[0] => Array
(
[ID] => 10231
[key] => field_5b215e4292273
[label] => Start Date
[name] => event_start_date
[prefix] => acf
[type] => date_picker
[value] => 12/19/2018
[menu_order] => 0
[instructions] => Date the event will start recurring.
[required] => 1
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10230
[wrapper] => Array
(
[width] => 15
[class] =>
[id] =>
)
[_name] => event_start_date
[_prepare] => 0
[_valid] => 1
[display_format] => m/d/Y
[return_format] => Ymd
[first_day] => 0
)
[1] => Array
(
[ID] => 10232
[key] => field_5b215e6292274
[label] => End Date
[name] => event_end_date
[prefix] => acf
[type] => date_picker
[value] =>
[menu_order] => 1
[instructions] => Leave blank if there is no end date.
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10230
[wrapper] => Array
(
[width] => 15
[class] =>
[id] =>
)
[_name] => event_end_date
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[display_format] => m/d/Y
[return_format] => Ymd
[first_day] => 0
)
[2] => Array
(
[ID] => 10233
[key] => field_5b215e9e92275
[label] => Recurring Week
[name] => event_recurring_week
[prefix] => acf
[type] => select
[value] =>
[menu_order] => 2
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10230
[wrapper] => Array
(
[width] => 14
[class] =>
[id] =>
)
[_name] => event_recurring_week
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[choices] => Array
(
[first] => First
[second] => Second
[third] => Third
[fourth] => Fourth
)
[default_value] => Array
(
)
[allow_null] => 0
[multiple] => 0
[ui] => 0
[ajax] => 0
[return_format] => value
[placeholder] =>
)
[3] => Array
(
[ID] => 10234
[key] => field_5b215eed92276
[label] => Day
[name] => event_recurring_day
[prefix] => acf
[type] => select
[value] =>
[menu_order] => 3
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10230
[wrapper] => Array
(
[width] => 14
[class] =>
[id] =>
)
[_name] => event_recurring_day
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[choices] => Array
(
[sunday] => Sunday
[monday] => Monday
[tuesday] => Tuesday
[wednesday] => Wednesday
[thursday] => Thursday
[friday] => Friday
[saturday] => Saturday
)
[default_value] => Array
(
[0] => friday
)
[allow_null] => 0
[multiple] => 0
[ui] => 0
[ajax] => 0
[return_format] => value
[placeholder] =>
)
[4] => Array
(
[ID] => 10257
[key] => field_5b216a933dfdc
[label] => Time
[name] => event_time
[prefix] => acf
[type] => repeater
[value] =>
[menu_order] => 4
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10230
[wrapper] => Array
(
[width] => 40
[class] =>
[id] =>
)
[_name] => event_time
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[collapsed] =>
[min] => 1
[max] => 0
[layout] => table
[button_label] => Add Time
[sub_fields] => Array
(
[0] => Array
(
[ID] => 10258
[key] => field_5b216aa53dfdd
[label] => Start Time
[name] => event_start_time
[prefix] => acf
[type] => select
[value] =>
[menu_order] => 0
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10257
[wrapper] => Array
(
[width] => 49
[class] =>
[id] =>
)
[_name] => event_start_time
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[choices] => Array
(
[06:00:00] => 6:00am
[06:15:00] => 6:15am
[06:30:00] => 6:30am
[06:45:00] => 6:45am
[07:00:00] => 7:00am
[07:15:00] => 7:15am
[07:30:00] => 7:30am
[07:45:00] => 7:45am
[08:00:00] => 8:00am
[08:15:00] => 8:15am
[08:30:00] => 8:30am
[08:45:00] => 8:45am
[09:00:00] => 9:00am
[09:15:00] => 9:15am
[09:30:00] => 9:30am
[09:45:00] => 9:45am
[10:00:00] => 10:00am
[10:15:00] => 10:15am
[10:30:00] => 10:30am
[10:45:00] => 10:45am
[11:00:00] => 11:00am
[11:15:00] => 11:15am
[11:30:00] => 11:30am
[11:45:00] => 11:45am
[12:00:00] => 12:00pm
[12:15:00] => 12:15pm
[12:30:00] => 12:30pm
[12:45:00] => 12:45pm
[13:00:00] => 1:00pm
[13:15:00] => 1:15pm
[13:30:00] => 1:30pm
[13:45:00] => 1:45pm
[14:00:00] => 2:00pm
[14:15:00] => 2:15pm
[14:30:00] => 2:30pm
[14:45:00] => 2:45pm
[15:00:00] => 3:00pm
[15:15:00] => 3:15pm
[15:30:00] => 3:30pm
[15:45:00] => 3:45pm
[16:00:00] => 4:00pm
[16:15:00] => 4:15pm
[16:30:00] => 4:30pm
[16:45:00] => 4:45pm
[17:00:00] => 5:00pm
[17:15:00] => 5:15pm
[17:30:00] => 5:30pm
[17:45:00] => 5:45pm
[18:00:00] => 6:00pm
[18:15:00] => 6:15pm
[18:30:00] => 6:30pm
[18:45:00] => 6:45pm
[19:00:00] => 7:00pm
[19:15:00] => 7:15pm
[19:30:00] => 7:30pm
[19:45:00] => 7:45pm
[20:00:00] => 8:00pm
[20:15:00] => 8:15pm
[20:30:00] => 8:30pm
[20:45:00] => 8:45pm
[21:00:00] => 10:00pm
[21:15:00] => 9:15pm
[21:30:00] => 9:30pm
[21:45:00] => 9:45pm
[22:00:00] => 10:00pm
[22:15:00] => 10:15pm
[22:30:00] => 10:30pm
[22:45:00] => 10:45pm
[23:00:00] => 11:00pm
[23:15:00] => 11:15pm
[23:30:00] => 11:30pm
[23:45:00] => 11:45pm
[00:00:00] => 12:00am
)
[default_value] => Array
(
[0] => 07:00:00
)
[allow_null] => 0
[multiple] => 0
[ui] => 0
[ajax] => 0
[return_format] => value
[placeholder] =>
)
[1] => Array
(
[ID] => 10259
[key] => field_5b216ad03dfde
[label] => End Time
[name] => event_end_time
[prefix] => acf
[type] => select
[value] =>
[menu_order] => 1
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 10257
[wrapper] => Array
(
[width] => 49
[class] =>
[id] =>
)
[_name] => event_end_time
[_prepare] => 0
[_valid] => 1
[user_roles] => Array
(
[0] => all
)
[choices] => Array
(
[06:00:00] => 6:00am
[06:15:00] => 6:15am
[06:30:00] => 6:30am
[06:45:00] => 6:45am
[07:00:00] => 7:00am
[07:15:00] => 7:15am
[07:30:00] => 7:30am
[07:45:00] => 7:45am
[08:00:00] => 8:00am
[08:15:00] => 8:15am
[08:30:00] => 8:30am
[08:45:00] => 8:45am
[09:00:00] => 9:00am
[09:15:00] => 9:15am
[09:30:00] => 9:30am
[09:45:00] => 9:45am
[10:00:00] => 10:00am
[10:15:00] => 10:15am
[10:30:00] => 10:30am
[10:45:00] => 10:45am
[11:00:00] => 11:00am
[11:15:00] => 11:15am
[11:30:00] => 11:30am
[11:45:00] => 11:45am
[12:00:00] => 12:00pm
[12:15:00] => 12:15pm
[12:30:00] => 12:30pm
[12:45:00] => 12:45pm
[13:00:00] => 1:00pm
[13:15:00] => 1:15pm
[13:30:00] => 1:30pm
[13:45:00] => 1:45pm
[14:00:00] => 2:00pm
[14:15:00] => 2:15pm
[14:30:00] => 2:30pm
[14:45:00] => 2:45pm
[15:00:00] => 3:00pm
[15:15:00] => 3:15pm
[15:30:00] => 3:30pm
[15:45:00] => 3:45pm
[16:00:00] => 4:00pm
[16:15:00] => 4:15pm
[16:30:00] => 4:30pm
[16:45:00] => 4:45pm
[17:00:00] => 5:00pm
[17:15:00] => 5:15pm
[17:30:00] => 5:30pm
[17:45:00] => 5:45pm
[18:00:00] => 6:00pm
[18:15:00] => 6:15pm
[18:30:00] => 6:30pm
[18:45:00] => 6:45pm
[19:00:00] => 7:00pm
[19:15:00] => 7:15pm
[19:30:00] => 7:30pm
[19:45:00] => 7:45pm
[20:00:00] => 8:00pm
[20:15:00] => 8:15pm
[20:30:00] => 8:30pm
[20:45:00] => 8:45pm
[21:00:00] => 10:00pm
[21:15:00] => 9:15pm
[21:30:00] => 9:30pm
[21:45:00] => 9:45pm
[22:00:00] => 10:00pm
[22:15:00] => 10:15pm
[22:30:00] => 10:30pm
[22:45:00] => 10:45pm
[23:00:00] => 11:00pm
[23:15:00] => 11:15pm
[23:30:00] => 11:30pm
[23:45:00] => 11:45pm
[00:00:00] => 12:00am
)
[default_value] => Array
(
[0] => 08:00:00
)
[allow_null] => 0
[multiple] => 0
[ui] => 0
[ajax] => 0
[return_format] => value
[placeholder] =>
)
)
)
)
)
)
)
So that’s part of the problem. You can’t update a field that is a sub field or a nested nested field with just the field key for that field. To use just the single field key it must be a top level field. To update a sub field you need to use update_sub_field()
https://www.advancedcustomfields.com/resources/update_sub_field/ and supply a selector that is an array that provides a path to the sub field, And I’m going to be honest, I don’t completely understand how this works.
Okay, I ended up writing some code that uses get_field_object() to build me a nested array tree that I can use to store data. The tree I built by hand had several mistakes in it because of how complex/convoluted it is.
Now it’s working.
I have to say that I am EXTREMELY disappointed in how ACF stores data and the extraordinary lengths I have to go through in order to work with complex forms. For non developers, ACF really is great, but for developers working on complex projects, it’s a nightmare.
The topic ‘update_field() inconsistency’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.