Using WP_User_Query object can’t retrieve any result

Question

I simply using WP_User_Query object to get a user by billing_phone ‘0988958792’ but the result return null.

function wooc_get_users_by_phone($phone_number){

  $args  = array(
     'meta_key' => 'billing_phone',
     'meta_value' => '0988958792'
  );

  $user_query = new WP_User_Query( $args );

  return $user_query->get_results();
}

enter image description here

The sql command in the server log is following but it does not retrieve any data.

SELECT SQL_CALC_FOUND_ROWS wp_users.* FROM wp_users 
INNER JOIN wp_usermeta ON ( wp_users.ID = wp_usermeta.user_id )  
INNER JOIN wp_usermeta AS mt1 ON ( wp_users.ID = mt1.user_id ) 
WHERE 1=1 AND ( 
( 
  ( 
    ( wp_usermeta.meta_key = 'billing_phone' AND wp_usermeta.meta_value = '0988958792' )
  ) 
AND 
( 
( 
( mt1.meta_key = 'wp_capabilities' AND mt1.meta_value NOT LIKE '%"administrator"%' ) 
AND 
( mt1.meta_key = 'wp_capabilities' AND mt1.meta_value NOT LIKE '%"editor"%' ) 
AND 
( mt1.meta_key = 'wp_capabilities' AND mt1.meta_value NOT LIKE '%"author"%' ) 
AND 
( mt1.meta_key = 'wp_capabilities' AND mt1.meta_value NOT LIKE '%"contributor"%' ) 
AND 
( mt1.meta_key = 'wp_capabilities' AND mt1.meta_value NOT LIKE '%"shop_manager"%' ) 
AND 
( mt1.meta_key = 'wp_capabilities' AND mt1.meta_value NOT LIKE '%"wpseo_manager"%' ) 
AND 
( mt1.meta_key = 'wp_capabilities' AND mt1.meta_value NOT LIKE '%"wpseo_editor"%'))))ORDER BY user_login ASC

Is the WP_User_Query object I’m using the wrong way or anything else I should change?

0
翁啟豪 5 months 2020-12-23T12:10:23-05:00 0 Answers 7 views 0

Leave an answer

Browse
Browse