WordPress at a glance
function is not described

cache_users() WP 3.0.0

Retrieve info for user lists to prevent multiple queries by get_userdata()

  • Global. wpdb. $wpdb WordPress database abstraction object.

This is a pluggable function, and it can be replaced from plugin. It means that this function is defined (works) only after all plugins are connected (included), but before this moment the function has not yet been defined... Therefore, you cannot call this and all functions depended on this function directly from a plugin code. It must be called via hook plugins_loaded or later, for example on hook init.

Function replacement (override) — in a plugin you can create a function with the same name, then it will replace this function.

No Hooks.

Return

Nothing (null).

Usage

cache_users( $user_ids );
$user_ids(array) (required)
User ID numbers list

Code of cache users: wp-includes/pluggable.php VER 5.0.3

<?php
function cache_users( $user_ids ) {
	global $wpdb;

	$clean = _get_non_cached_ids( $user_ids, 'users' );

	if ( empty( $clean ) )
		return;

	$list = implode( ',', $clean );

	$users = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($list)" );

	$ids = array();
	foreach ( $users as $user ) {
		update_user_caches( $user );
		$ids[] = $user->ID;
	}
	update_meta_cache( 'user', $ids );
}