A WordPress-centric search engine for devs and theme authors



cache_users ›

Since3.0.0
Deprecatedn/a
cache_users ( $user_ids )
Parameters:
  • (array) $user_ids User ID numbers list
    Required: Yes
Defined at:
Codex:

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



Source

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 );
	}
endif;

if ( ! function_exists( 'wp_mail' ) ) :