WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

wp_get_users_with_no_role() WP 4.4.0

Get the user IDs of all users with no role on this site.

Хуков нет.

Возвращает

Массив. Array of user IDs.

Использование

wp_get_users_with_no_role( $site_id );
$site_id(число/null)
The site ID to get users with no role for.
По умолчанию: current site

Список изменений

С версии 4.4.0 Введена.
С версии 4.9.0 The $site_id parameter was added to support multisite.

Код wp get users with no role: wp-includes/user.php WP 5.2.3

<?php
function wp_get_users_with_no_role( $site_id = null ) {
	global $wpdb;

	if ( ! $site_id ) {
		$site_id = get_current_blog_id();
	}

	$prefix = $wpdb->get_blog_prefix( $site_id );

	if ( is_multisite() && $site_id != get_current_blog_id() ) {
		switch_to_blog( $site_id );
		$role_names = wp_roles()->get_names();
		restore_current_blog();
	} else {
		$role_names = wp_roles()->get_names();
	}

	$regex = implode( '|', array_keys( $role_names ) );
	$regex = preg_replace( '/[^a-zA-Z_\|-]/', '', $regex );
	$users = $wpdb->get_col(
		$wpdb->prepare(
			"
		SELECT user_id
		FROM $wpdb->usermeta
		WHERE meta_key = '{$prefix}capabilities'
		AND meta_value NOT REGEXP %s
	",
			$regex
		)
	);

	return $users;
}