Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Member / Profile fields by URL?

  • Avatar of perywinkle
    perywinkle
    Participant

    @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?
    Ex.
    /members/s?field=State&value=Idaho

    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 5 replies - 1 through 5 (of 5 total)
  • Avatar of perywinkle
    perywinkle
    Participant

    @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”

    Avatar of yoramz
    yoramz
    Member

    @yoramz

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

    Avatar of shanebpdev
    shanebpdev
    Participant

    @shanebp

    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.

    http://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-members-loop/

    Avatar of kaformedia
    kaformedia
    Participant

    @kaformedia

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

    Avatar of perywinkle
    perywinkle
    Participant

    @perywinkle

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

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

You must be logged in to reply to this topic.