admin管理员组文章数量:1130349
I using get_users to get users from my database.
I am using this code:
$args = array (
'role' => 'Colaborador',
'role__not_in' =>[ 'subscriber', 'Administrator'],
'orderby' => 'rand'
);
$users = get_users($args );
But in the output when use the foreach to print the data I need I found that are some user that are duplicate, appearing twice in the array.
How can i fix this?
I using get_users to get users from my database.
I am using this code:
$args = array (
'role' => 'Colaborador',
'role__not_in' =>[ 'subscriber', 'Administrator'],
'orderby' => 'rand'
);
$users = get_users($args );
But in the output when use the foreach to print the data I need I found that are some user that are duplicate, appearing twice in the array.
How can i fix this?
Share Improve this question asked Oct 30, 2018 at 20:07 Rivero FelipeRivero Felipe 31 bronze badge1 Answer
Reset to default 0I think it's arguments issue.
I recommend not to use role & role__not_in together rather either use only role OR use role__in & role__not_in combination. Also check your role param spelling. (see more on role)
2ndly orderby param rand is not valid according to codex (see here) so use proper param.
I using get_users to get users from my database.
I am using this code:
$args = array (
'role' => 'Colaborador',
'role__not_in' =>[ 'subscriber', 'Administrator'],
'orderby' => 'rand'
);
$users = get_users($args );
But in the output when use the foreach to print the data I need I found that are some user that are duplicate, appearing twice in the array.
How can i fix this?
I using get_users to get users from my database.
I am using this code:
$args = array (
'role' => 'Colaborador',
'role__not_in' =>[ 'subscriber', 'Administrator'],
'orderby' => 'rand'
);
$users = get_users($args );
But in the output when use the foreach to print the data I need I found that are some user that are duplicate, appearing twice in the array.
How can i fix this?
Share Improve this question asked Oct 30, 2018 at 20:07 Rivero FelipeRivero Felipe 31 bronze badge1 Answer
Reset to default 0I think it's arguments issue.
I recommend not to use role & role__not_in together rather either use only role OR use role__in & role__not_in combination. Also check your role param spelling. (see more on role)
2ndly orderby param rand is not valid according to codex (see here) so use proper param.
本文标签: arrayHow to avoid duplicate users when I am using getusers
版权声明:本文标题:array - How to avoid duplicate users when I am using get_users? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749218406a2334552.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论