Ecommerce Shopify WordPress Discussion

Trying to search users by phone number in admin user.php

I have a multisite setup and I am trying to search users by billing phone. I am used the snippet below but for some reason the search result is finding 729 items and displaying only 1 per page even though I only have 4 users with that same billing phone and the screen options is set to show 20 items per page. If I change the screen setting to show 729 items per page, it shows 14 users(10 of which I deleted) but it is still finding 729 items. // Modify user search query to include searching by billing phone function custom_user_search_by_billing_phone($query) { global $wpdb; // Check if we are in the admin and performing a user search if (is_admin() && isset($_GET['s'])) { $search_term = sanitize_text_field($_GET['s']); // Check if the search term resembles a phone number if (preg_match('/^\+?[\d()-]+$/', $search_term)) { // Modify the user search query to include searching by billing phone $query->query_where .= " OR {$wpdb->users}.ID IN (SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = 'billing_phone' AND meta_value LIKE '%$search_term%')"; } } } add_action('pre_user_query', 'custom_user_search_by_billing_phone');
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.