cache_users( int[] $user_ids )

In this article

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

Parameters

$user_idsint[]required
User ID numbers list

Source

function cache_users( $user_ids ) {
	global $wpdb;

	update_meta_cache( 'user', $user_ids );

	$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)" );

	foreach ( $users as $user ) {
		update_user_caches( $user );
	}
}

Changelog

VersionDescription
3.0.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.