Skip to:
Content
Pages
Categories
Search
Top
Bottom

MEMBER SEARCH OR FILTER BY CUSTOM FIELD

  • Avatar of jamers_786
    jamers_786
    Participant

    @jamers_786

    FIRST OF ALL THANKS TO ALL WHERE THE DIRECTION AND COPY THE CODE..I SETUP STEP BY STEP BECAUSE I AM BIGINNER ALSO. I KNOW WHEN EXPERTS TALKING OR WRITE THE CODE DIDN’T UNDERSTAND BIGINNERS LIKE ME

    <form  method="Post" id="searchform" action="http://www.jamersweb.com/montreal/en/demo"/>
    <input type="radio" name="language" id="language" value="English">EN
    <input type="radio" name="language" id="language1" value="french">FR
    
    <input type="radio" name="wed-type" id="wed-type" value="local wedding">Local wedding
    <input type="radio" name="wed-type" id="wed-type1" value="willing to travel">Willing to travel
    
    <select name="budget" id-"budget">
      <option selected="selected" disabled="disabled">Select Category</option>
      <option value="2000">2000-10000</option>
      <option value="12000$">12000-20000</option>
      <option value="4000$">22000-30000</option>
    </select>
    
    <select name="style" id-"style">
      <option selected="selected" disabled="disabled">Select Category</option>
      <option value="wedding">wedding</option>
      <option value="party">party</option>
      <option value="dancing">dancing</option>
    </select> 
    <input type="submit">
    </form>
    <?php 
    $one = $_POST['language'];
    $two = $_POST['budget'];
    $three = $_POST['style'];
    /*
    STEP 1 CHECK THE VALUE OF FORM FIELDS
    echo $one;
    echo $two;
    echo $three;
    */
    ?>
     <?php
    /*   
    STEP 2 MAKE THE QUERY OF DATABASE
    
    */
     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");
    
    /*   
    STEP 3 CHECK THE QUERY RETURN IN ARRAY
    
    */
    print_r($result);
    /*   
    STEP 4 CONVERT OBJECT ARRAY INTO SEPARTED COMMA STRING
    
    */
    $str_ids = '';
        foreach($result as $r) {
             $str_ids .= ('' == $str_ids) ? '' : ', ';
             $str_ids .= $r->user_id;
        }
       // print_r($str_ids);
    /*   
    STEP 5 EXPLODE THE DUPLICATE STRINGS
    
    */
    $arr = explode( " " , $str_ids );
    $arr = array_unique( $arr );
    $str_ids = implode(" " , $arr);
    
    $get_these_members = $str_ids;
    //echo $get_these_members;
    /*   
    STEP 6 INCLUDE THE MEMBERS OF BUDDYPRESS
    
    */
    $get_these_members = 'include=' . substr($get_these_members, 0, -1);
    
    ?>
    /*   
    STEP 7 JUST ADD THE VARIABLE INTO IF CONDITION OF LOOPS AND GET THE MEMBER BY ANY PROFILE FIELD
    
    */
     
    <?php if ( bp_has_members($get_these_members) ) : ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Avatar of shanebp
    shanebp
    Moderator

    @shanebp

    FIRST OF ALL THERE IS NO NEED TO SHOUT.
    WE CAN HEAR YOU JUST FINE WHEN YOU talk like this.

    Please don’t paste big chunks of code here.
    Please use pastebin or gist and then paste the link here.

    You don’t describe the problem that you may be having when you run your code.
    Please describe what you’ve done, the file in which you did it, what happened, and the versions of WordPress and BuddyPress that you’re using.

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    And why did you post that code block on it’s own into a 4 year old thread without any sort of mention as to why? Please try not to do that :) I’m removing that post on the other thread.

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

You must be logged in to reply to this topic.