Support » Plugin: Improved user search in backend » Search first and last name

  • 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);
    }

    http://wordpress.org/plugins/improved-user-search-in-backend/

Viewing 4 replies - 1 through 4 (of 4 total)
  • @justin_gigasavvy – Great idea & thanks for the enhancement.

    @blackbam – will you consider this for an enhancement in an upcoming release?

    Yes, great enhancement. I would also like to request that this be put into an upcoming release of the plugin. Thanks!

    I did notice a similar issue with custom meta fields. I used the WP-Members plugin to create the meta fields and I’ve added the ones I want to search for to the User Search Custom Meta Fields box.

    I’m using “company_name” as an example: When I search for a 2 part company name like “XYZ Corp” I get no search results, however if I type in part of the company name “XYZ” by itself or “Corp” by itself I get results.

    I implemented this, and it still does not return a result when searching for both first and last name.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Search first and last name’ is closed to new replies.