I have a taxonomy with an ACF repeater field. I am trying to add rows in a callback for a custom REST API endpoint and having no luck. The scheme for the field is:
{
"key": "field_5faa2bc09fe7b",
"label": "team",
"name": "team",
"type": "repeater",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"collapsed": "",
"min": 0,
"max": 10,
"layout": "table",
"button_label": "",
"sub_fields": [
{
"key": "field_5faa2bce9fe7c",
"label": "Role",
"name": "role",
"type": "post_object",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"post_type": [
"role"
],
"taxonomy": "",
"allow_null": 0,
"multiple": 0,
"return_format": "id",
"ui": 1
},
{
"key": "field_5faa2c0b9fe7d",
"label": "User",
"name": "user",
"type": "user",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"role": "",
"allow_null": 0,
"multiple": 0,
"return_format": "id"
}
]
}
I use the following to add a row to the field - and having no luck:
function wp_api_assign_internal_writer() {
register_rest_route( 'mynamespace/v1', 'assign_internal_writer/', array(
'methods' => 'POST',
'callback' => 'assign_internal_writer_callback',
));
}
function assign_internal_writer_callback( $request ) {
$parameters = $request->get_params();
$task = $parameters['task'];
$user = $parameters['user'];
$project_set = $parameters['project_set'];
if($task != '' && $user != '' && $project_set != '' ){
$row = array(
'field_5faa2bce9fe7c' => '268',
'field_5faa2c0b9fe7d' => $user
);
add_row('team', $row, $project_set);
return get_term_meta($project_set);
}else{
return 'Please supply the correct request parameters, Task ID and User ID';
}
}
Any idea what I am doing wrong? Does add row work only for Post and not Term....? I doubt thats it...