Hi there, having a little trouble inserting new data to a repeater row. This solution here works:
http://stackoverflow.com/questions/24879399/wordpress-acf-how-to-add-rows-to-a-repeater-field-attached-to-a-user-via-custom?lq=1
But only if I have already added a row of data to the user record via the admin editor.
If it does not already have an existing record and I attempt to push the array it only inserts the field name and saves the JSON instead of generation the field key.
Is there a way to create / setup the repeater data if it doesn’t already exist for the user? I can only see update functions but no create… but there must be one somewhere as you can do it via the admin?
Thanks
Ok finally figured this out (documentation isn’t very clear on this one)
If you have zero rows to start with you need to do this:
$field_key = “field_5657dffe586cc”;
$value = get_field($field_key, ‘user_24’);
$value[] = array(“career_enjoyment_id” => “Foo”, “career_enjoyment_file” => “Bar”);
update_field( $field_key, $value, ‘user_24’ );
The $field_key is located in the wordpress posts table assigned to the main repeater. Use the ID from post_name.