users - WP_User_Query by meta_value with Number returns nothing

admin2025-06-04  2

When querying users with WP_User_Query by meta_value like '23432' (as string or integer) it returns nothing. If searched by text like 'admin' it returns all users where meta_value equals 'admin'.

    $user_query = new WP_User_Query(
        array(
            'number' => 1,
            'meta_query' => array(
                array(
                    'key'     => 'customer_id',
                    'value'   => '23432',
                    'compare' => 'LIKE'
                )
            )
        )
    );

    $users = $user_query->get_results();

The meta_value = '23432' is in the wp_usermeta table at meta_key = 'customer_id' and by search in MySQL it returns the right entry.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748968215a315239.html

最新回复(0)