要通过ID获取用户列表,只需添加include
你的质疑的论据;
$args [
\'include\' => [ 1, 2, 3, 4 ], // Get users of these IDs.
\'fields\' => [ \'ID\', \'user_email\', \'display_name\', \'user_url\' ],
];
$users = get_users( $args );
您不需要使用
number
参数,因为您已经通过中提供的ID数量限制了结果
include
.
See this page for more info on the available arguments.您也可以使用WP_User_Query
类来检索它们;
$args [
\'include\' => [ 1, 2, 3, 4 ], // Get users of these IDs.
\'fields\' => [ \'ID\', \'user_email\', \'display_name\', \'user_url\' ],
];
$user_search = new WP_User_Query( $args );
$users = $user_search->get_results();