[wp-trac] [WordPress Trac] #22212: WP_User_Query( array('role' => $role) ) should accept array or not return anything if array
WordPress Trac
noreply at wordpress.org
Wed Oct 17 12:37:44 UTC 2012
#22212: WP_User_Query( array('role' => $role) ) should accept array or not return
anything if array
-----------------------------+--------------------------
Reporter: thomask | Type: defect (bug)
Status: new | Priority: normal
Milestone: Awaiting Review | Component: Users
Version: | Severity: normal
Keywords: |
-----------------------------+--------------------------
I got a small problem with WP_User_Query - i wanted to find users from
more then one roles to send them e-mail, so i did
{{{
$role = array('role-1','role-2);
$wp_user_search = WP_User_Query( array('role' => $role) );
$users = $wp_user_search->get_results()
foreach ($user) ... send wp_mail
}}}
problem is, that role param accepts only string. It would not be a problem
if it would return nothing, problem was, that it actually returns ALL
users, so i have send my author-only emails to all thousands users in
database :-(
I know that it is my fault, that i have to read documentation, but i
thought, that it works as other wp queries, so if the parame do not fit,
it throws error, but it does not.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/22212>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list