REST API and filtering by meta value

Add a third parameter in the get_post_meta() function as true, that will return the single value of the current post meta, if you don’t set it it will return an array of the values.

What is happening now is that internally the query is trying to compare the meta_value with an array instead of a string or integer and that’s why you don’t get any results.

Also, your requested data should be the same name as the query params indicated in the current endpoint, if you put:

/wp-json/wp/v2/timeslip?meta_key=user_id&meta_value=1

Then you access to the request data as:

$request['meta_key'];
$request['meta_value'];

You originally set the requested data as:

$request['timeslip_user_id'];
$request['timeslip_user_id'];

So your query filter function should looks like this:

function timeslip_meta_request_params( $args, $request ) {
    $args['meta_key']   = $request['meta_key'];
    $args['meta_value'] = $request['meta_value'];

    return $args;
}

I just tested the code in a local env, check that the user_id field is an string. Hope if works for you:

enter image description here