filters - add_filter( 'user_has_cap','my_function', 10, 3 ); and call to get_users in my functio

I use:add_filter( 'user_has_cap','my_function', 10, 3 ); In user list to allow users to edit only a

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1736599697a3904310.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信