Skip to:

Search Member / Profile fields by URL?

  • perywinkle


    I’m working on a member directory.
    I’m interested in creating a search that queries ONLY a certain field ‘State’ and value ‘Idaho’.
    I’m wondering if I can pass this to the search via the url?

    A search for Idaho shows the members in Idaho,
    but it also displays anyone that has entered ‘Idaho’ in their profile.
    I need to develop a more rigid search based on the field ‘State’.

Viewing 6 replies - 1 through 6 (of 6 total)

  • perywinkle


    The other option I’ve been toying with is creating the State values: as Idaho_state ( more specific search term )
    Then display state as “Idaho” ( in the profile ) with some php:
    if value “Idaho – ID”
    echo “Idaho”

    i’m looking for the same things to do with my site.
    did you find a solution for that?



    I’d approach this a different way –

    something like:
    $match_ids = $wpdb->get_var( “SELECT user_id FROM wp_bp_xprofile_data WHERE field_id = [whatever the field_id is for State] AND value = [whatever value you want to find] “);

    $match_ids will be a simple array.
    So loop thru the array and create a comma separated string out of the ids.
    Then pass the string to bp_has_members() using ‘include’

    something like
    //$get_these_members is the id string you created
    $get_these_members = ‘include=’ . substr($get_these_members, 0, -1); //trim the last comma

    if ( bp_has_members( $get_these_members ) )

    That way you could search for any value on any profile field.
    Your approach might work, but… yikes.



    Ok where do you put the code and how can we make it for role.



    Hey Thanks @shanebp
    I’ll give that a try…

    Mohammad Raheel


    hi thanks @shanebp i am really biggner for my self i did what you said but matter is when i tried but never got result kindly check my code tell me i already spend 4 days.

    global $wpdb, $bp;
    $result = $wpdb->get_results(“SELECT user_id FROM wp_bp_xprofile_data WHERE value = ‘$_POST[language]’ OR value = ‘$_POST[budget]’ OR value = ‘$_POST[style]’LIMIT 0 , 30”);
    $result = array();
    //$values = maybe_unserialize($result);
    //echo var_dump( maybe_unserialize( $result ) );
    //$values = $result;
    //$value = bp_unserialize_profile_user_id( $values );
    //$values = implode( “, “, $value);
    //echo $values;
    //so you have to ‘manually’ unserialize them
    foreach($result as $user_id=>%d)
    echo “Key=” . $user_id . “, Value=” . %d;
    echo “<br>”;
    //$values_str = implode( ‘,’, $getty );


    echo $get_these_members;
    $get_these_members = ‘include=’ . substr($get_these_members, 0, -1);


Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Search Member / Profile fields by URL?’ is closed to new replies.
Skip to toolbar