I have an array of user IDs, I want to get data for each of these users. I first thought of writing a classic SQL query but I found WordPress has integreted functions for it. However, get_users(…) is only returning me 1 users though it should return 3. What am I doing wrong?
$targetUsers = get_users([‘include’ => $targetUsersIDs]);
Output of var_dump($targetUsersIDs);
public ‘ID’ => string ‘1’ (length=1)
public ‘ID’ => string ‘2’ (length=1)
public ‘ID’ => string ‘4’ (length=1)
Start of the output of var_dump(targetUsers);
Somebody suggested to use
$targetUsers = get_users([‘include’ => wp_list_pluck($targetUsersIDs,’ID’)]);
This apparently works, but not, I was about to check it as answer and I see that the answer has disappeared. Why? Did they realise there is actually something wrong with it? Because so far it seems to work.
Read more here:: get_users(…) only returns one user