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.

本文标签: