您可以使用get_users()
函数两次以排除subscribers
.
你可以这样做
// Gets all the subscribers
$user_query = get_users( array( \'role\' => \'subscriber\' ) );
// This gets the array of ids of the subscribers
$subscribers_id = wp_list_pluck( $user_query, \'ID\' );
// Now use the exclude parameter to exclude the subscribers
$non_subscribers = get_users( array( \'exclude\' => $subscribers_id ) );
$non_subscribers
包含非订阅服务器。
您可以获取display_name
通过这样做
foreach( $non_subscribers as $non_subscriber ) {
echo $non_subscriber->display_name;
}