[wp-hackers] Help with get_users()

Mike Walsh mpwalsh8 at gmail.com
Wed Sep 25 02:29:23 UTC 2013


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


More information about the wp-hackers mailing list