how to get list of all users and their metadata

Question

How do I get a list of all users with role = ‘Customers’ including all the metadata per user, means wp_users + wp_usermeta.

Query below does not generate the wanted results.

    $query = "SELECT * FROM wp_users INNER JOIN wp_usermeta ON wp_users.ID = wp_usermeta.user_id ORDER BY ID DESC');  ";

    $data = $wpdb->get_results($query,ARRAY_A);

But that list is not correct. It shows each user x times depend of the amount of rows in wp_usermeta.

How can i filter it? That each user shows per record all his user + metadata?

Still searching for 6 hours.

0
, Hermants 7 years 2016-06-29T07:45:38-05:00 0 Answers 57 views 0

Leave an answer

Browse
Browse