I haven’t got any luck with my SQL query to get users with role subscriber:
SELECT
ID,
display_name
FROM 'wp_users'
INNER JOIN 'wp_usermeta' ON 'wp_users'.ID = 'wp_usermeta'.user_id
WHERE 'wp_usermeta'.meta_key = 'wp_capabilities'
AND ('wp_usermeta'.meta_value LIKE 'subscriber') ORDER BY display_name
Can any body help me?
I have got the answer to my question:
If anybody struggling with the same issue please use my SQL query above.
Here’s a slight variant of @qqruza’s answer that includes the user’s email and role and returns users for all roles.
If you have a WordPress multisite installation, to get the roles for all child sites, use:
Of course, you’ll need to look at the
wp_usermeta.meta_key
value to determine which child site (blog) the record applies to.This Worked for me :
I’m not familiar with the WordPress internal structure, but I can tell you that your
LIKE
statement is probably wrong. There’s no implicit/automatic wildcards in the LIKE argument, so what you have (with no wildcards) is basically the same as using=
. Ie. you probably want:You can use:
If you want to grab other metainfo you can use subqueries, just remember the more subqueries, the slower the overall query is going to be.