REST API: Limit search_columns for users without list_users.

Props Vortfu, jorbin, joehoyle, timothyblynjacobs, peterwilsoncc, ehtis.





git-svn-id: https://develop.svn.wordpress.org/trunk@56833 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jb Audras
2023-10-12 12:28:57 +00:00
parent 698880552f
commit 26007fbc48
2 changed files with 22 additions and 0 deletions

View File

@@ -318,6 +318,9 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
}
if ( ! empty( $prepared_args['search'] ) ) {
if ( ! current_user_can( 'list_users' ) ) {
$prepared_args['search_columns'] = array( 'ID', 'user_login', 'user_nicename', 'display_name' );
}
$prepared_args['search'] = '*' . $prepared_args['search'] . '*';
}
/**