I have a custom plugin which queries users and usermeta, but I now need to filter admins out of the results. A very simplified version of my sql query is:
SELECT * FROM usermeta LEFT JOIN users ON users.ID = user_id
WHERE meta_key = 'last_name' AND
user_role != 'admin'
ORDER BY meta_value
ASC LIMIT 0, 25
user_role
is not a field, and i saw how it is stored as a config string, but i don’t see how to make an equivalent query to this. Am i missing something?
Thanks.
You can use this function:
The 3rd line within the function did not work for me as
array_walk
returns a boolean instead of the desired array. I’ve changed line 3 to:And it works for me now.