[wp-hackers] Help with get_users()

Chris McCoy chris at lod.com
Wed Sep 25 03:06:15 UTC 2013


Why not use the wp user query?

http://codex.wordpress.org/Class_Reference/WP_User_Query




On 2013-09-24 10:29 PM, "Mike Walsh" <mpwalsh8 at gmail.com> wrote:

>I am trying to use get_users() to retrieve a collection of users based on
>some meta data.  So far, I have been unsuccessful.  I want to use
>get_users() replace this query.
>
>$query = " SELECT ID, display_name, user_email, user_login, "
>            . "m1.meta_value first_name, m2.meta_value last_name, "
>            . "m3.meta_value massemail, m4.meta_value notifications "
>            . "FROM $wpdb->users u "
>            . "LEFT JOIN $wpdb->usermeta m1 ON "
>            . "(m1.user_id = u.ID AND m1.meta_key = 'first_name') "
>            . "LEFT JOIN $wpdb->usermeta m2 ON "
>            . "(m2.user_id = u.ID AND m2.meta_key = 'last_name') "
>            . "LEFT JOIN $wpdb->usermeta m3 ON "
>            . "(m3.user_id = u.ID AND m3.meta_key = '" .
>MAILUSERS_ACCEPT_MASS_EMAIL_USER_META . "') "
>            . "LEFT JOIN $wpdb->usermeta m4 ON "
>            . "(m4.user_id = u.ID AND m4.meta_key = '" .
>MAILUSERS_ACCEPT_NOTIFICATION_USER_META . "') " ;
>
>
>I am not sure something like this is possible with get_users(), but if
>anyone has any pointers to something similar I can look at I'd appreciate
>any pointers.
>
>-- 
>Mike Walsh - mpwalsh8 at gmail.com
>_______________________________________________
>wp-hackers mailing list
>wp-hackers at lists.automattic.com
>http://lists.automattic.com/mailman/listinfo/wp-hackers




More information about the wp-hackers mailing list