• 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://wordpress.org/plugins/improved-user-search-in-backend/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Luca

    (@lucarosaldi)

    I investigated this issue: looks like the problem is in lines 98-100:

    if(preg_match('/^[a-zA-Z0-9,]+$/',$sanitized)) {
    	update_option('iusib_meta_fields',$sanitized);
    }

    I’m no regex expert, so I don’t know what’s the purpose of the expression, but the update_option function just does not run, no matter what you put into the textarea.

    I removed the “if” statement altogether (line 98 and 100), but this threw another error for a deprecated function, this time in line 54. So I fixed that as well.

    These are the code updates:

    Line 54:
    $iusib_add = " OR meta_key='".implode("' OR meta_key='",esc_sql($iusib_cma))."'";

    Lines 98-100 (change the 3 lines with the following one):
    update_option('iusib_meta_fields',$sanitized);

    Now the plugin works as expected.

    By the way, this is a wonderful function that should be included in the core IMHO.

    Thanks so much for your code LucaRosaldi – This helped a lot when I was wondering what was going on as well.

    Much appreciated!
    Roger Sanchez

    I too am having issues with user meta fields not working properly in the search. I tried reinstalling the plugin fresh (v 1.2.6) and implementing LucaRosaldi’s code modifications, unfortunately I’m not having any luck getting proper search results from the meta fields.

    Earlier, I also tried this: https://wordpress.org/support/topic/search-first-and-last-name and no luck there either.

    I’m not sure whether that has an influence over the search results but my meta fields have been set up through the WP-Members plugin:
    https://wordpress.org/plugins/wp-members/

    I would love to know how to solve this one.

    Thanks,
    Mike S

    I ran into this issue as well. I found that entering something like “abc,def,ghi” would save properly, but something like “billing_first_name,billing_last_name” would not. So I turned to the regular expression used. I added the underscore (_) character to the end of the regex and it saved properly: /^[a-zA-Z0-9,]+$/

    Hi dale3h,

    Thanks for your response. Since I’m not super savvy with regular expressions, can you specify exactly where the underscore went?

    I’m not sure if the end means:
    /^[a-zA-Z0-9,]+$/_

    or

    /^[a-zA-Z0-9,_]+$/

    or something else.

    Also, was this with LucaRosaldi’s fix or without?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘custom fields do not search’ is closed to new replies.