rcp_get_customers

Query for customers.

Parameters:

  • $args (array) - Array of arguments, all of which are optional:
    • $id (int) - A customer ID to only return that customer. Default empty.
    • $id__in (array) - An array of customer IDs. Default empty.
    • $id__not_in (array) - An array of customer IDs to exclude from the results. Default empty.
    • $user_id (int) - A user ID to filter by. Default empty.
    • $user_id__in (array) - An array of user IDs. Default empty.
    • $user_id__not_in (array) - An array of user IDs to exclude from the results. Default empty.
    • $email_verification (string) - Filter by email verification status. Accepts: verified, pending, and none. Default empty.
    • $date_registered_query (array) - Date query clauses to limit customers by. See WP_Date_Query. Default empty.
    • $last_login_query (array) - Date query clauses to limit customers by. See WP_Date_Query. Default empty.
    • $count (bool) - Whether to return a customer count (true) or an array of customer objects (false). Default false.
    • $fields (string) - Item fields to return. Accepts any known column name, or empty to return an array of complete customer objects. Default empty.
    • $number (int) - Limit the number of results. Default 20.
    • $offset (int) - Number of customers to offset. Default 20.
    • $no_found_rows (bool) Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true.
    • $orderby (string) - Accepts id', 'date_registered', and 'last_login'. Also accepts false, an empty array, or 'none' to disable `ORDER BY` clause. Default 'id'.
    • $order (string) - How to order results. Accepts `ASC` and `DESC`. Default `DESC.
    • $search (string) - Search term(s) to retrieve matching customers for. This searches most of the above customer columns. Default empty.
    • $update_cache (bool) - Whether to prime the cache for found customers. Default false.

Return values:

Examples:

Return customers that match any of the included user ID numbers:

$customers = rcp_get_customers( array(
    'user_id__in' => array( 5, 73, 41, 104 )
) );

Return the customer ID numbers of all customers pending email verification:

$customer_ids = rcp_get_customers( array(
    'email_verification' => 'pending',
    'fields' => 'id'
) );