Utilities::get_users_with_meta( array $exact_meta_keys = array(), array $fuzzy_meta_keys = array(), array $included_user_ids = array() )
!!! ALPHA FUNCTION – NEEDS TESTING/BENCHMARKING
Contents
Description Description
Get User data with meta keys’ value
In some cases we need to loop a lot of users’ data. If we need 1000 user with there user meta values we would normally run WP User Query, then loop the user and run get_user_meta() on each iteration which will return the specified user meta and also collect/store ALL the user meta. In case above, WP will run 1 query for the user loop and 1000 user meta queries; 1001 queries will run. WP will also store all the data collected in memory, if each user has 100 metas stores then 1000 x 100 metas is 100 000 values.
With this function if we run the same scenrio as above, 2 quieries will run and only the amount of data points that are specifically needed. 1000 users
Todo Maybe add optional transient Todo Benchmarking needed
Only Returns this first meta_key value. Does not support multiple meta_values per single key.
Parameters Parameters
- $exact_meta_keys
-
(Optional)
Default value: array()
- $fuzzy_meta_keys
-
(Optional)
Default value: array()
- $included_user_ids
-
(Optional)
Default value: array()
Return Return
(array)
Source Source
File: src/utilities.php
Expand full source code Collapse full source code View on Github