Advanced member filter

Hi guys, I'm sorry for this, but I searched everything by now, and all I can find is some old outdated info about this and plugins who used to work, but don't work anymore in 1.8

I need a form where users can filter members and search for them.
Looking at the search hooks, and the info I found, it looks to me as not such a big work, but I just don't know where to start.

this works for instance:
This displays all the users with 'testword' in their profile.

What I would like to see is:

I don't need a fancy plugin with a userinterface, I can make the form myself, but I just need to know how I can start making the search ready to to search specific profilefields with specific values.

Anyone caring to help me out with this?

  • Hm... maybe something like this: Register a handler for the 'search', 'user' hook. Inside the handler you can then do:

    $profilefield1 = get_input('profilefield1');
    $profilefield2 = get_input('profilefield2');

    And build your own query:

        'type' => 'user',
        'metadata_name_value_pairs' = array(
                'name' => 'profilefield1',
                'value' => $profilefield1,
                'name' => 'profilefield2',
                'value' => $profilefield2,

  • ...or actually I suppose you should add each individual field only IF user has entered them:

    $fields = array('field1', 'field2', etc...);
    $name_value_pairs = array();
    foreach ($fields as $field) {
        $value = get_input($field);
        if ($value) {
            $name_value_pairs[] = array(
                'name' => $field,
                'value' => $value,

    $options['metadata_name_value_pairs'] = $name_value_pairs;

  • Thanks a lot, I'll try to figure something out :)

  • @juho.jaakkola  how would you suggest to add some extra strings inside the $name_value_pairs code you posted? For example some fields need operand to be > or <. I have field that needs to find value larger and/or smaller than value selected in the form dropdown field but other fields do not need specific operand.

    Much appreciated.

  • Does anyone know if 1.8 supports 'operand'=>'>=', in elgg_list_entities_from_metadata($options) code?

    I'm using "metadata_name_value_pairs" and need to find metadata values equal to/larger than first input field value and smaller than/equal to second filed value. Basiaclly I have two fields and need to find metadata between two numbers (selected by these two fields).


  • Any valid sql operator should be possible