admin管理员组文章数量:1123854
I use:
add_filter( 'user_has_cap','my_function', 10, 3 );
In user list to allow users to edit only a specific list of users with a meta user identical to a current user connected.
To get the list of users I use get_users($args);
but this triggers an infinite loop.
I guess somewhere get_users
calls user_has_cap
again.
I try to remove_filter before get_users($args);
, this works but the filter only works the first time in my user list.
I try to add add_filter( 'user_has_cap','my_function', 10, 3 );
after get_users($args);
but again this triggers an infinite loop.
remove_filter( 'user_has_cap', __FUNCTION__ );
$user_ids = get_users($args);
add_filter( 'user_has_cap', 'author_cap_filter', 10, 3 );
My other solution is to write a SQL query with $wpdb->get_results
.
本文标签:
版权声明:本文标题:filters - add_filter( 'user_has_cap','my_function', 10, 3 ); and call to get_users in my functio 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736599696a1945194.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论