Hey all!
I have a custom post type using the ACF “user” field to allow you to select a target user (it is a todo task, so it already has an “author”).
I need to be able to do a get_posts for this if I know a user ID, but no syntax seems to work, and the user field is undocumented.
For example, this doesn’t work…
$posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'example_type',
'meta_key' => 'target_user',
'meta_value' => $current_user->ID
));
Any ideas?
Hi @soulhuntre
Your code looks good, make sure all the follow are correct:
1. $current_user->ID is valid data (print_r it to debug)
2. check postmeta table and find a value that your field has stored. What does the data look like. Is it a single ID? or is it an array?
3. print_r the result of $posts. What do you get?
Hi Elliot,
I have almost the same question but using the Repeater Field.
The Repeater Field slug is “membres_du_groupe” and inside there is the user “membre”.
The issue is that the post_meta is like :
membres_du_groupe_0_membre
membres_du_groupe_1_membre
membres_du_groupe_2_membre ...
Could you help me with this?
Thanks very much