Question on searching on custom fields

Discussion in 'Customization & add-ons' started by underscoretom, May 24, 2008.

  1. underscoretom

    underscoretom Guest

    Joined:
    Aug 3, 2006
    Messages:
    22
    As many do, we have custom fields set up for our members. When searching on these fields, any field that can have multiple values never returns search results.

    I can search on other custom fields that only have a single value, but ones that can have multiple don't seem to work.

    Is there any trick to this before I write custom code to do this?
  2. underscoretom

    underscoretom Guest

    Joined:
    Aug 3, 2006
    Messages:
    22
    I'll assume by the silence that there's no way to do this. What a shame.

    Time whip up a bunch of LIKEs
  3. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    When you say search are you referring to from the Admin CP or from your website?

    In theory the data is in SQL so it is searchable, just not currently exposed via interface.
  4. underscoretom

    underscoretom Guest

    Joined:
    Aug 3, 2006
    Messages:
    22
    I'm on the search users page in CP Admin.

    I have a couple custom fields that are multi-valued. By default, the "additional fields" are added to the default search functionality. Selecting any of those radio buttons for fields that can have multiple values results in no values returned. Searching on custom fields that aren't multi-valued return the expected results.

    Is users_find_by_string the only method available to query with? Or is there a more generic one available? users_find_by_string doesn't seem like it'd support a series of OR clauses.
  5. underscoretom

    underscoretom Guest

    Joined:
    Aug 3, 2006
    Messages:
    22
    Surely someone has had the need to do this before.
  6. jimjwright

    jimjwright New Member

    Joined:
    Sep 12, 2007
    Messages:
    162
    Hello,

    What version of aMember are you using? I was able to modify the function users_find_by_string() located in mysql.inc.php in version 3.1.0 of aMember to fix the problem you are experiencing.

    I created a custom field "mypets" and set multiple select values of "cat, dog, gorilla" and was able to find users that matched a single select value. In other words the search string had to be for either "cat", "dog", or "gorilla". You could not combine them. If you wanted a more complicated search string that matched multiple values to a user such as "cat OR dog" or "dog AND gorilla" then that would be more complicated and would require more work.

    Jimmy
  7. underscoretom

    underscoretom Guest

    Joined:
    Aug 3, 2006
    Messages:
    22
    We're still on 3.0.8.

    The only thing I have in my mysql.inc.php file is includes to the ionCube/Zend loaders.

    I tried looking for that function definition, but obviously it's all obfuscated in the ioncube stuff.
  8. underscoretom

    underscoretom Guest

    Joined:
    Aug 3, 2006
    Messages:
    22
    Hmm...looking at 3.1.1, seems they've extracted some of those functions back into mysql.inc.php. Looks like i'm upgrading sooner rather than later
  9. barisko

    barisko New Member

    Joined:
    Dec 13, 2008
    Messages:
    9
    Is this fixed yet?

    I downloaded aMember Pro 3.1.4TRIAL but I can not search on custom fields with multiple values. This is a real problem for me/us.

    It would be even better if it is possible to search for "cat OR dog" or "dog AND gorilla" (as in the example of jimjwright)
  10. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    Did you just call jimjwright a Gorilla? wow..
  11. barisko

    barisko New Member

    Joined:
    Dec 13, 2008
    Messages:
    9
    When searching on custom fields, any field that can have multiple values never returns search results.

    Is there a solution for this problem?
  12. pahcsor

    pahcsor New Member

    Joined:
    Aug 28, 2006
    Messages:
    9
    3 Years and no solution???

    I hate to wake up an old thread, but in 3 years there has never been a solution to this??? I have searched the amember forum to find what I needed, and this is the only thread discussing this question.

    My problem is related in that I built a custom member search plugin based on users.php from the admin section. Works great after customizing, etc., but members cannot search any custom fields that contain multiple values (in this case, designations).

    Can anyone provide an answer to this three years later? Thank you!!!
  13. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Search by additional fields with multiple values should work if you use latest version.
    Here is example that you can use:
    PHP:
    $users users_find_by_string("searchstr""additional:fieldname"0);
    Above will search for "searchstr" in all values fr additional field fieldname;

Share This Page