Not sure if this is actively maintained now, but if you need to support it under PHP7, there is a relatively simple change you can make (beware of the plugin being overwritten by auto-updating in future…)
On line 50, change:
$qstr = mysql_real_escape_string($_GET[“s”]);
to:
$qstr = esc_attr($_GET[“s”]);
]]>This plugin does not currently work with PHP 7. WordPress is supporting it, so you’ll need to consider to keep current. This plugin as currently written is not usable with PHP 7 as mysql_real_escape_string was deprecated in PHP 5.5 and completely removed in PHP 7.
You have some time since PHP 5.6 is not slated for EOL for a while yet, but by Jan 2017 (just six months from now), PHP 7 will be the current active version.
https://www.ads-software.com/plugins/improved-user-search-in-backend/
]]>I’m trying this out but, settings page does not save custom field values entered. Any plans on getting this to work with latest WP?
Also wondering how scalable is the plugin. i.g. can it perform searches quick enough for a site with more than 10,000 users where each user account has 20 custom fields?
Thank you!
Bowo
https://www.ads-software.com/plugins/improved-user-search-in-backend/
]]>My site has about 36k users. Searching these users in the admin has been very slow, taking about 20 seconds on average.
I ran the P3 plugin profiler while searching for users multiple times. The average time this plugin took while loading the page was 8 seconds.
Is there anything that can be done to make user searches load faster?
https://www.ads-software.com/plugins/improved-user-search-in-backend/
]]>Hello,
I found an issue with the plugin not functioning due to the mysql_real_escape_string, I found nothing was being returned except the following errors;
WARNING: wp-content/plugins/improved-user-search-in-backend/improved-user-search-in-backend.php:50 - mysql_real_escape_string(): Access denied for user '***'@'localhost' (using password: NO)
WP_Users_List_Table->prepare_items, WP_User_Query->__construct, WP_User_Query->prepare_query, do_action_ref_array, call_user_func_array, user_search_by_multiple_parameters, mysql_real_escape_string
WARNING: wp-content/plugins/improved-user-search-in-backend/improved-user-search-in-backend.php:50 - mysql_real_escape_string(): A link to the server could not be established
WP_Users_List_Table->prepare_items, WP_User_Query->__construct, WP_User_Query->prepare_query, do_action_ref_array, call_user_func_array, user_search_by_multiple_parameters, mysql_real_escape_string
Looking into the error it appears the function is deprecated for PHP 5.5, I tried the msqli version ( mysqli_real_escape_string but that requires a db connection. I found that establishing one can be avoided by simply using the wpdb escape function $wpdb->escape()
. So the fix is to update line 50 as follows;
$qstr = $wpdb->escape($_GET["s"]);
Hope this helps someone.
Cheers
https://www.ads-software.com/plugins/improved-user-search-in-backend/
]]>Hello,
Some hosters have made a move to PHP 5.5. This makes mysql_real_escape_string break; can you update the plugin to use the built-in wpdb escape function?
Change from
$qstr = mysql_real_escape_string($_GET[“s”]);
to
$qstr = $wpdb->_real_escape($_GET[“s”]);
and probably
$iusib_add = ” OR meta_key='”.implode(“‘ OR meta_key='”,$wpdb->escape($iusib_cma)).”‘”;
to
$iusib_add = ” OR meta_key='”.implode(“‘ OR meta_key='”,$wpdb->_real_escape($iusib_cma)).”‘”;
thank you!
https://www.ads-software.com/plugins/improved-user-search-in-backend/
]]>I’m working on a WordPress website that has user database with important user information, so this user information need to searched thoroughly.
As shown in this picture:
https://i.stack.imgur.com/vFeWm.png
I have a custom registration fields, and I’ve found your plugin so that I’m able search for country (like: syria) and all the syria
results will be listed.
But I need to make it work on a multiple criteria (like: Syria unemployed
) it would need all the Syrian users who set “unemployed” as their occupation. so is this possible? what edits I need to make to the plugin to make it work?
https://www.ads-software.com/plugins/improved-user-search-in-backend/
]]>I’m trying to set a couple usermeta fields in the Custom field search box in the User search settings, but no matter what I try the setting won’t save. I’ve entered just one, multiple comma-delimited, and entered with and without quotes around each. I click Save, but the field just clears.
Is this related to the issue with custom field search, discussed here? https://www.ads-software.com/support/topic/custom-fields-do-not-search?replies=4
https://www.ads-software.com/plugins/improved-user-search-in-backend/
]]>I have added a list of custom fields into the options area, these are set correctly and the same fields are showing in the usermeta table but these will not return in a search.
As a work around I’ve manually added the select statements.
Thought it might be worth making you aware, I am not 100% sure on the cause of the custom fields section failing to apply the options to the search.
https://www.ads-software.com/plugins/improved-user-search-in-backend/
]]>Hi,
I just wanted to see if you’re planning to make a multisite version of this plugin. That’s what I’m looking for and haven’t found anything like that available. I see it was discussed previously so I just wanted to see if there are any new developments.
Thanks
https://www.ads-software.com/plugins/improved-user-search-in-backend/
]]>Hi.
On line 54 of improved-user-search-in-backend.php you have used wpdb->escape() which has become deprecated.
Notice: wpdb::escape is deprecated since version 3.6! Use wpdb::prepare() or esc_sql() instead. in /wp-includes/functions.php on line 2908
Could you fix this? (Turning off notices is not a solution)
Thanks!
– Tim
https://www.ads-software.com/plugins/improved-user-search-in-backend/
]]>Hi,
Is there a way to search posts by email?
https://www.ads-software.com/plugins/improved-user-search-in-backend/
]]>I noticed your plugin fails when you search for both first and last name. Here is the fix to that. Simply open “improved-user-search-in-backend/improved-user-search-in-backend.php”
Locate this code… (around line 57)
$usermeta_affected_ids = $wpdb->get_results(“SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE (meta_key=’first_name’ OR meta_key=’last_name'”.$iusib_add.”) AND LOWER(meta_value) LIKE ‘%”.$qstr.”%'”);”
Put this code below it …
if( count(explode(" ", $qstr)) == 2 ) {
$usermeta_sql = "
SELECT
DISTINCT user_id,
GROUP_CONCAT(meta_value SEPARATOR ' ') as full_name
FROM
$wpdb->usermeta
WHERE
(meta_key = 'first_name' OR meta_key = 'last_name')
GROUP BY
user_id
HAVING
full_name
LIKE '%".$qstr."%'";
$usermeta_affected_ids = $wpdb->get_results($usermeta_sql);
}
https://www.ads-software.com/plugins/improved-user-search-in-backend/
]]>Hi,
first of all great and essential plugin!
I have implemented both WP standard metakeys and my own (created via Gravity forms). Unfortunately I don’t manage to get search results when I search for numbers, such as registration date (typed in the meta tags of course). When I search “1” I only get results for people using number one in their username. Nowhere else.
Have somebody any clue what I’m doing wrong?
All the best,
Rikard
https://www.ads-software.com/plugins/improved-user-search-in-backend/
]]>Unless I’m missing something, I can’t search for users by their display name. Would you please consider adding this functionality to the plugin?
Thank you very much for your work.
https://www.ads-software.com/plugins/improved-user-search-in-backend/
]]>Hi,
Plugin is not working in multisite environment.
Is there a update comming up for this?
Kinds regards,
Sven
https://www.ads-software.com/extend/plugins/improved-user-search-in-backend/
]]>I started working on an extension of this plugin to WP Multisite, but have not gotten too far. I reset the options page as a subpage instead, and attempted to implement a naive search improvement based on this: https://www.ads-software.com/support/topic/using-user-search?replies=23#post-2131280
However, I did not see results. Would be interested in properly porting the single-site improvement to the network admin user page, but unsure of how the network search query is constructed.
Code thus far:
<?php
/*
Plugin Name: Improved User Search in Backend
Plugin URI: https://www.blackbam.at/blackbams-blog/2011/06/27/wordpress-improved-user-search-first-name-last-name-email-in-backend/
Description: Improves the search for users in the backend significantly: Search for first name, last, email and more of users instead of only nicename.
Version: 1.2.3
Author: David St?ckl
Author URI: https://www.blackbam.at/
*/
/* version check */
global $wp_version;
if(version_compare($wp_version,"3.0","<")) {
exit('Improved User Search in Backend requires WordPress version 3.0 or higher. <a href="https://codex.www.ads-software.com/Upgrading_Wordpress">Please update!</a>');
}
// all of this is only for admin interface, is_admin does not check for admin user role
if( is_admin() ) {
// add the overwrite actions for the search
if (!is_network_admin() ) {
add_action('pre_user_query', 'user_search_by_multiple_parameters');
}
/*if ( is_network_admin() ) {
add_action('pre_user_query', 'network_user_search_by_multiple_parameters');
}*/
// add the backend menu page
if (!is_network_admin() ) {
add_action('admin_menu','improved_user_search_in_backend_options');
}
/*if ( is_network_admin() ) {
add_action('network_admin_menu','improved_user_search_in_backend_network_options');
}*/
// network search improvement option
/* function network_user_search_by_multiple_parameters($wp_user_query) {
echo "Hello three";
if(false === strpos($wp_user_query->query_where, '@') && !empty($_GET["s"])) {
$wp_user_query->query_where = str_replace(
"user_nicename LIKE '%".mysql_real_escape_string($_GET["s"])."%'",
"user_nicename LIKE '%".mysql_real_escape_string($_GET["s"])."%'
OR user_login LIKE '%".mysql_real_escape_string($_GET["s"])."%'
OR display_name LIKE '%".mysql_real_escape_string($_GET["s"])."%'
OR user_email LIKE '%".mysql_real_escape_string($_GET["s"])."%'", $wp_user_query->query_where);
}
return $wp_user_query;
} */
// the actual improvement of the query
function user_search_by_multiple_parameters($wp_user_query) {
if(false === strpos($wp_user_query->query_where, '@') && !empty($_GET["s"])) {
global $wpdb;
$uids=array();
// get the custom meta fields to search
$iusib_custom_meta = get_option('iusib_meta_fields');
$iusib_cma = explode(",",$iusib_custom_meta);
$iusib_add = "";
// the escaped query string
$qstr = mysql_real_escape_string($_GET["s"]);
// add all custom fields into the query
if(!empty($iusib_cma)) {
$iusib_add = " OR meta_key='".implode("' OR meta_key='",$wpdb->escape($iusib_cma))."'";
}
$usermeta_affected_ids = $wpdb->get_results("SELECT DISTINCT user_id FROM $wpdb->usermeta WHERE (meta_key='first_name' OR meta_key='last_name'".$iusib_add.") AND LOWER(meta_value) LIKE '%".$qstr."%'");
foreach($usermeta_affected_ids as $maf) {
array_push($uids,$maf->user_id);
}
$users_affected_ids = $wpdb->get_results("SELECT DISTINCT ID FROM $wpdb->users WHERE LOWER(user_nicename) LIKE '%".$qstr."%' OR LOWER(user_email) LIKE '%".$qstr."%'");
foreach($users_affected_ids as $maf) {
if(!in_array($maf->ID,$uids)) {
array_push($uids,$maf->ID);
}
}
$id_string = implode(",",$uids);
$wp_user_query->query_where = str_replace("user_nicename LIKE '%".$qstr."%'", "ID IN(".$id_string.")", $wp_user_query->query_where);
}
return $wp_user_query;
}
// add the options page
function improved_user_search_in_backend_options() {
if (!is_network_admin() ) {
add_options_page('User Search','User Search',
'manage_options',__FILE__,'improved_user_search_in_backend_page');
}
}
// add the network options page
/* function improved_user_search_in_backend_network_options() {
if ( is_network_admin() ) {
add_submenu_page('settings.php','User Search','User Search',
'manage_options',__FILE__,'improved_user_search_in_backend_page');
}
}*/
// add the options page
function improved_user_search_in_backend_page() { ?>
<div class="wrap">
<div><?php screen_icon('options-general'); ?></div>
<h2>Settings: Improved user search in backend</h2>
<?php
if(isset($_POST['improved_user_search_in_backend_update']) && $_POST['improved_user_search_in_backend_update']!="") {
// remove whitespace
$sanitized = implode(",",array_map('trim', explode(",",$_POST['iusib_meta_fields'])));
update_option('iusib_meta_fields',stripslashes($sanitized)); ?>
<div id="setting-error-settings_updated" class="updated settings-error">
<p><strong><?php _e('Settings saved successfully.','improved-user-search-in-backend'); ?></strong></p>
</div>
<?php } ?>
<form name="improved_user_search_in_backend_update" method="post" action="">
<div>
<table class="form-table">
<tr valign="top">
<th scope="row">Custom Meta Fields (comma seperated)</th>
<td><textarea name="iusib_meta_fields" rows="6" cols="50"><?php echo get_option('iusib_meta_fields'); ?></textarea></td>
<td class="description">Add custom user meta fields from your usermeta table for integration in the user search (e.g. "url", "description", "aim", or custom like "birthday")</td>
</tr>
</table>
<p></p>
<p><input type="hidden" name="improved_user_search_in_backend_update" value="true" />
<input type="submit" name="Save" value="Save Settings" class="button-primary" /></p>
</div>
</form>
</div>
<?php }
}
register_activation_hook(__FILE__,"improved_user_search_in_backend_activate");
function improved_user_search_in_backend_activate() {
register_uninstall_hook(__FILE__,"improved_user_search_in_backend_uninstall");
}
function improved_user_search_in_backend_uninstall() {
// delete all options, tables, ...
delete_option('iusib_meta_fields');
}
?>
https://www.ads-software.com/extend/plugins/improved-user-search-in-backend/
]]>I uploaded this to my plug-ins folder, but can’t find it anywhere in their – in either activated or de-activated sections. Am I doing something wrong?
https://www.ads-software.com/extend/plugins/improved-user-search-in-backend/
]]>great plugin! i have a custom usermeta field that i want to search on. i took your code and easily added in the extra field to the usermeta select statement, and it works great.
if you’re in the mood to improve your plugin, others may benefit if you gave the ability to add custom usermeta fields names into the plugin config so they wouldn’t have to modify the code as i did.
just a suggestion, but i know that maintaining a plugin and adding features is a lot of work.
thanks again.
mkm
https://www.ads-software.com/extend/plugins/improved-user-search-in-backend/
]]>