WordPress.org

Make WordPress Core

Opened 19 months ago

Closed 19 months ago

Last modified 19 months ago

#46126 closed defect (bug) (invalid)

WP_User_Query by meta_value with Number returns nothing

Reported by: juliantroeps Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.0.3
Component: Users Keywords:
Focuses: Cc:

Description

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'.

<?php
    $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.

Change History (6)

#1 @navnitviradiya13
19 months ago

I have checked and its working fine. It might other issue.

This ticket was mentioned in Slack in #core by navnitviradiya13. View the logs.


19 months ago

#3 @navnitviradiya13
19 months ago

  • Resolution set to invalid
  • Status changed from new to closed

#4 @navnitviradiya13
19 months ago

  • Keywords close added

#5 @navnitviradiya13
19 months ago

  • Keywords close removed

#6 @desrosj
19 months ago

  • Milestone Awaiting Review deleted

Removing Awaiting Review milestone from closed tickets.

Note: See TracTickets for help on using tickets.